Better error messages when failure to send due to:

- no internet
- unregistered recipient

// FREEBIE
pull/1/head
Michael Kirk 9 years ago
parent 3e10a49258
commit b6676fb029

@ -270,9 +270,8 @@ NSString *const OWSMessageSenderInvalidDeviceException = @"InvalidDeviceExceptio
? self.storageManager.localNumber
: contactThread.contactIdentifier;
__block SignalRecipient *recipient = [SignalRecipient recipientWithTextSecureIdentifier:recipientContactId];
SignalRecipient *recipient = [SignalRecipient recipientWithTextSecureIdentifier:recipientContactId];
if (!recipient) {
NSError *error;
// possibly returns nil.
recipient = [self.contactsUpdater synchronousLookup:contactThread.contactIdentifier error:&error];
@ -281,6 +280,8 @@ NSString *const OWSMessageSenderInvalidDeviceException = @"InvalidDeviceExceptio
if (error.code == NOTFOUND_ERROR) {
DDLogWarn(@"recipient contact not found with error: %@", error);
[self unregisteredRecipient:recipient message:message thread:thread];
NSError *error = OWSErrorMakeNoSuchSignalRecipientError();
return failureHandler(error);
}
DDLogError(@"contact lookup failed with error: %@", error);
return failureHandler(error);
@ -462,7 +463,7 @@ NSString *const OWSMessageSenderInvalidDeviceException = @"InvalidDeviceExceptio
switch (statuscode) {
case 404: {
[self unregisteredRecipient:recipient message:message thread:thread];
NSError *error = OWSErrorMakeFailedToSendOutgoingMessageError();
NSError *error = OWSErrorMakeNoSuchSignalRecipientError();
return failureHandler(error);
}
case 409: {

@ -134,11 +134,12 @@ typedef void (^failureBlock)(NSURLSessionDataTask *task, NSError *error);
case 0: {
DDLogWarn(@"The network request failed because of a connectivity error.");
failureBlock(task,
[self errorWithHTTPCode:statusCode
description:NSLocalizedString(@"NETWORK_ERROR_DESC", nil)
failureReason:networkError.localizedFailureReason
recoverySuggestion:NSLocalizedString(@"NETWORK_ERROR_RECOVERY", nil)
fallbackError:networkError]);
[self errorWithHTTPCode:statusCode
description:NSLocalizedString(@"ERROR_DESCRIPTION_NO_INTERNET",
@"Generic error used whenver Signal can't contact the server")
failureReason:networkError.localizedFailureReason
recoverySuggestion:NSLocalizedString(@"NETWORK_ERROR_RECOVERY", nil)
fallbackError:networkError]);
break;
}
case 400: {

@ -19,5 +19,6 @@ typedef NS_ENUM(NSInteger, OWSErrorCode) {
extern NSError *OWSErrorWithCodeDescription(OWSErrorCode code, NSString *description);
extern NSError *OWSErrorMakeUnableToProcessServerResponseError();
extern NSError *OWSErrorMakeFailedToSendOutgoingMessageError();
extern NSError *OWSErrorMakeNoSuchSignalRecipientError();
NS_ASSUME_NONNULL_END

@ -25,4 +25,11 @@ NSError *OWSErrorMakeFailedToSendOutgoingMessageError()
NSLocalizedString(@"ERROR_DESCRIPTION_CLIENT_SENDING_FAILURE", @"Generic notice when message failed to send."));
}
NSError *OWSErrorMakeNoSuchSignalRecipientError()
{
return OWSErrorWithCodeDescription(OWSErrorCodeFailedToSendOutgoingMessage,
NSLocalizedString(
@"ERROR_DESCRIPTION_UNREGISTERED_RECIPIENT", @"Error message when attempting to send message"));
}
NS_ASSUME_NONNULL_END

Loading…
Cancel
Save