Include reusable localized text in recipient-not-found error

This way we can use it for calls as well.

// FREEBIE
pull/1/head
Michael Kirk 9 years ago
parent 7ca1d5e8a6
commit 7b1b706e2a

@ -10,8 +10,6 @@ NS_ASSUME_NONNULL_BEGIN
@interface ContactsUpdater : NSObject @interface ContactsUpdater : NSObject
#define NOTFOUND_ERROR 777404
+ (instancetype)sharedUpdater; + (instancetype)sharedUpdater;
- (nullable SignalRecipient *)synchronousLookup:(NSString *)identifier error:(NSError **)error; - (nullable SignalRecipient *)synchronousLookup:(NSString *)identifier error:(NSError **)error;

@ -66,9 +66,7 @@ NS_ASSUME_NONNULL_BEGIN
if (matchedIds.count == 1) { if (matchedIds.count == 1) {
success([SignalRecipient recipientWithTextSecureIdentifier:identifier]); success([SignalRecipient recipientWithTextSecureIdentifier:identifier]);
} else { } else {
failure([NSError errorWithDomain:@"contactsmanager.notfound" failure(OWSErrorMakeNoSuchSignalRecipientError());
code:NOTFOUND_ERROR
userInfo:nil]);
} }
} }
failure:failure]; failure:failure];

@ -286,13 +286,12 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
recipient = [self.contactsUpdater synchronousLookup:recipientContactId error:&error]; recipient = [self.contactsUpdater synchronousLookup:recipientContactId error:&error];
if (error) { if (error) {
if (error.code == NOTFOUND_ERROR) { if (error.code == OWSErrorCodeNoSuchSignalRecipient) {
DDLogWarn(@"recipient contact not found with error: %@", error); DDLogWarn(@"%@ recipient contact not found", self.tag);
[self unregisteredRecipient:recipient message:message thread:thread]; [self unregisteredRecipient:recipient message:message thread:thread];
NSError *error = OWSErrorMakeNoSuchSignalRecipientError();
return failureHandler(error);
} }
DDLogError(@"contact lookup failed with error: %@", error);
DDLogError(@"%@ contact lookup failed with error: %@", self.tag, error);
return failureHandler(error); return failureHandler(error);
} }
} }

@ -20,6 +20,7 @@ typedef NS_ENUM(NSInteger, OWSErrorCode) {
OWSErrorCodeSignalServiceFailure = 1001, OWSErrorCodeSignalServiceFailure = 1001,
OWSErrorCodeSignalServiceRateLimited = 1010, OWSErrorCodeSignalServiceRateLimited = 1010,
OWSErrorCodeUserError = 2001, OWSErrorCodeUserError = 2001,
OWSErrorCodeNoSuchSignalRecipient = 777404,
}; };
extern NSError *OWSErrorWithCodeDescription(OWSErrorCode code, NSString *description); extern NSError *OWSErrorWithCodeDescription(OWSErrorCode code, NSString *description);

Loading…
Cancel
Save