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

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

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

@ -25,4 +25,11 @@ NSError *OWSErrorMakeFailedToSendOutgoingMessageError()
NSLocalizedString(@"ERROR_DESCRIPTION_CLIENT_SENDING_FAILURE", @"Generic notice when message failed to send.")); 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 NS_ASSUME_NONNULL_END

Loading…
Cancel
Save