mirror of
https://github.com/signalapp/libsignal.git
synced 2024-09-19 19:42:19 +02:00
Use failOnError instead of try! in Swift
Replace existing usages of try! with the failOnError helper. Add guidance to the coding guidelines doc.
This commit is contained in:
parent
1359b67486
commit
ac538311e9
@ -73,6 +73,8 @@ These should usually be prioritized in that order, but adjust the trade-off as n
|
||||
|
||||
- **Write API docs** using [DocC syntax][] (a Markdown dialect), unless an API is trivial (or not app-team-facing). Even for internal methods, though, if you do write a comment, make it a doc comment (like for Rust code), because it shows up in IDEs.
|
||||
|
||||
- To make sure that error messages get into logs, we use the `failOnError` helper instead of `try!` for forcing an unwrap on the result of an operation that can throw an error.
|
||||
|
||||
[DocC syntax]: https://www.swift.org/documentation/docc/writing-symbol-documentation-in-your-source-files
|
||||
|
||||
|
||||
|
@ -75,9 +75,11 @@ public struct MessageBackupUnknownFields {
|
||||
|
||||
private class ValidationOutcome: NativeHandleOwner {
|
||||
public var unknownFields: MessageBackupUnknownFields {
|
||||
let fields = try! self.withNativeHandle { result in
|
||||
try invokeFnReturningStringArray {
|
||||
signal_message_backup_validation_outcome_get_unknown_fields($0, result)
|
||||
let fields = failOnError {
|
||||
try self.withNativeHandle { result in
|
||||
try invokeFnReturningStringArray {
|
||||
signal_message_backup_validation_outcome_get_unknown_fields($0, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
return MessageBackupUnknownFields(fields: fields)
|
||||
|
@ -198,7 +198,9 @@ public class SenderCertificate: NativeHandleOwner {
|
||||
}
|
||||
|
||||
public var sender: SealedSenderAddress {
|
||||
return try! SealedSenderAddress(e164: self.senderE164, uuidString: self.senderUuid, deviceId: self.deviceId)
|
||||
return failOnError {
|
||||
try SealedSenderAddress(e164: self.senderE164, uuidString: self.senderUuid, deviceId: self.deviceId)
|
||||
}
|
||||
}
|
||||
|
||||
public var serverCertificate: ServerCertificate {
|
||||
|
Loading…
Reference in New Issue
Block a user