exception auditing OWSRaiseException

pull/1/head
Michael Kirk 7 years ago
parent 3a6aafc454
commit 9d2731c9b8

@ -40,7 +40,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSString *)migrationId + (NSString *)migrationId
{ {
OWSRaiseException(NSInternalInconsistencyException, @"Must override %@ in subclass", NSStringFromSelector(_cmd)); OWSAbstractMethod();
return @"";
} }
+ (NSString *)collection + (NSString *)collection
@ -51,7 +52,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)runUpWithTransaction:(YapDatabaseReadWriteTransaction *)transaction - (void)runUpWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
{ {
OWSRaiseException(NSInternalInconsistencyException, @"Must override %@ in subclass", NSStringFromSelector(_cmd)); OWSAbstractMethod();
} }
- (void)runUpWithCompletion:(OWSDatabaseMigrationCompletion)completion - (void)runUpWithCompletion:(OWSDatabaseMigrationCompletion)completion

@ -159,7 +159,7 @@ NSString *const TSAccountManager_NeedsAccountAttributesUpdateKey = @"TSAccountMa
NSString *phoneNumber = self.phoneNumberAwaitingVerification; NSString *phoneNumber = self.phoneNumberAwaitingVerification;
if (!phoneNumber) { if (!phoneNumber) {
OWSRaiseException(@"RegistrationFail", @"Internal Corrupted State"); OWSFail(@"phonNumber was unexpectedly nil");
} }
[self storeLocalNumber:phoneNumber]; [self storeLocalNumber:phoneNumber];

@ -213,8 +213,7 @@ NS_ASSUME_NONNULL_BEGIN
// We need to use an Intel certificate as the anchor for IAS verification. // We need to use an Intel certificate as the anchor for IAS verification.
NSData *_Nullable anchorCertificate = [self certificateDataForService:@"ias-root"]; NSData *_Nullable anchorCertificate = [self certificateDataForService:@"ias-root"];
if (!anchorCertificate) { if (!anchorCertificate) {
OWSFailDebug(@"could not load anchor certificate."); OWSFail(@"could not load anchor certificate.");
OWSRaiseException(@"OWSSignalService_CouldNotLoadCertificate", @"%s", __PRETTY_FUNCTION__);
} else { } else {
anchorCertificates = @[ anchorCertificate ]; anchorCertificates = @[ anchorCertificate ];
} }

@ -839,7 +839,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
NSArray<NSDictionary *> *deviceMessages; NSArray<NSDictionary *> *deviceMessages;
@try { @try {
deviceMessages = [self deviceMessagesForMessageSendUnsafe:messageSend]; deviceMessages = [self try_deviceMessagesForMessageSendUnsafe:messageSend];
} @catch (NSException *exception) { } @catch (NSException *exception) {
if ([exception.name isEqualToString:UntrustedIdentityKeyException]) { if ([exception.name isEqualToString:UntrustedIdentityKeyException]) {
// This *can* happen under normal usage, but it should happen relatively rarely. // This *can* happen under normal usage, but it should happen relatively rarely.
@ -1407,8 +1407,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
[self sendMessageToRecipient:messageSend]; [self sendMessageToRecipient:messageSend];
} }
// NOTE: This method uses exceptions for control flow. - (NSArray<NSDictionary *> *)try_deviceMessagesForMessageSendUnsafe:(OWSMessageSend *)messageSend
- (NSArray<NSDictionary *> *)deviceMessagesForMessageSendUnsafe:(OWSMessageSend *)messageSend
{ {
OWSAssertDebug(messageSend.message); OWSAssertDebug(messageSend.message);
OWSAssertDebug(messageSend.recipient); OWSAssertDebug(messageSend.recipient);
@ -1444,7 +1443,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
@try { @try {
// This may involve blocking network requests, so we do it _before_ // This may involve blocking network requests, so we do it _before_
// we open a transaction. // we open a transaction.
[self ensureRecipientHasSessionForMessageSend:messageSend deviceId:deviceId]; [self try_ensureRecipientHasSessionForMessageSend:messageSend deviceId:deviceId];
__block NSDictionary *messageDict; __block NSDictionary *messageDict;
__block NSException *encryptionException; __block NSException *encryptionException;
@ -1486,9 +1485,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
return [messagesArray copy]; return [messagesArray copy];
} }
// NOTE: This method uses exceptions for control flow. - (void)try_ensureRecipientHasSessionForMessageSend:(OWSMessageSend *)messageSend deviceId:(NSNumber *)deviceId
- (void)ensureRecipientHasSessionForMessageSend:(OWSMessageSend *)messageSend
deviceId:(NSNumber *)deviceId
{ {
OWSAssertDebug(messageSend); OWSAssertDebug(messageSend);
OWSAssertDebug(deviceId); OWSAssertDebug(deviceId);

Loading…
Cancel
Save