2017-02-01 16:21:50 +01:00
|
|
|
//
|
2018-03-26 15:37:43 +02:00
|
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
2017-02-01 16:21:50 +01:00
|
|
|
//
|
2016-08-26 16:01:53 +02:00
|
|
|
|
|
|
|
#import "OWSError.h"
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
NSString *const OWSSignalServiceKitErrorDomain = @"OWSSignalServiceKitErrorDomain";
|
2017-12-22 00:01:40 +01:00
|
|
|
NSString *const OWSErrorRecipientIdentifierKey = @"OWSErrorKeyRecipientIdentifier";
|
2016-08-26 16:01:53 +02:00
|
|
|
|
2016-08-29 23:03:24 +02:00
|
|
|
NSError *OWSErrorWithCodeDescription(OWSErrorCode code, NSString *description)
|
2016-08-26 16:01:53 +02:00
|
|
|
{
|
|
|
|
return [NSError errorWithDomain:OWSSignalServiceKitErrorDomain
|
|
|
|
code:code
|
|
|
|
userInfo:@{ NSLocalizedDescriptionKey: description }];
|
|
|
|
}
|
|
|
|
|
2016-10-14 23:00:29 +02:00
|
|
|
NSError *OWSErrorMakeUnableToProcessServerResponseError()
|
|
|
|
{
|
|
|
|
return OWSErrorWithCodeDescription(OWSErrorCodeUnableToProcessServerResponse,
|
|
|
|
NSLocalizedString(@"ERROR_DESCRIPTION_SERVER_FAILURE", @"Generic server error"));
|
|
|
|
}
|
|
|
|
|
|
|
|
NSError *OWSErrorMakeFailedToSendOutgoingMessageError()
|
|
|
|
{
|
|
|
|
return OWSErrorWithCodeDescription(OWSErrorCodeFailedToSendOutgoingMessage,
|
|
|
|
NSLocalizedString(@"ERROR_DESCRIPTION_CLIENT_SENDING_FAILURE", @"Generic notice when message failed to send."));
|
|
|
|
}
|
|
|
|
|
2016-10-25 15:54:43 +02:00
|
|
|
NSError *OWSErrorMakeNoSuchSignalRecipientError()
|
|
|
|
{
|
2017-02-02 01:18:28 +01:00
|
|
|
return OWSErrorWithCodeDescription(OWSErrorCodeNoSuchSignalRecipient,
|
2016-10-25 15:54:43 +02:00
|
|
|
NSLocalizedString(
|
|
|
|
@"ERROR_DESCRIPTION_UNREGISTERED_RECIPIENT", @"Error message when attempting to send message"));
|
|
|
|
}
|
|
|
|
|
2018-04-04 22:26:41 +02:00
|
|
|
NSError *OWSErrorMakeAssertionError(NSString *description)
|
2016-12-18 22:08:26 +01:00
|
|
|
{
|
2018-08-27 16:29:51 +02:00
|
|
|
OWSCFailDebug(@"Assertion failed: %@", description);
|
2018-04-04 22:26:41 +02:00
|
|
|
return OWSErrorWithCodeDescription(OWSErrorCodeAssertionFailure,
|
|
|
|
NSLocalizedString(@"ERROR_DESCRIPTION_UNKNOWN_ERROR", @"Worst case generic error message"));
|
2017-02-01 16:21:50 +01:00
|
|
|
}
|
|
|
|
|
2017-12-22 00:01:40 +01:00
|
|
|
NSError *OWSErrorMakeUntrustedIdentityError(NSString *description, NSString *recipientId)
|
|
|
|
{
|
|
|
|
return [NSError
|
|
|
|
errorWithDomain:OWSSignalServiceKitErrorDomain
|
|
|
|
code:OWSErrorCodeUntrustedIdentity
|
|
|
|
userInfo:@{ NSLocalizedDescriptionKey : description, OWSErrorRecipientIdentifierKey : recipientId }];
|
|
|
|
}
|
|
|
|
|
2017-02-10 19:20:11 +01:00
|
|
|
NSError *OWSErrorMakeMessageSendDisabledDueToPreKeyUpdateFailuresError()
|
|
|
|
{
|
|
|
|
return OWSErrorWithCodeDescription(OWSErrorCodeMessageSendDisabledDueToPreKeyUpdateFailures,
|
|
|
|
NSLocalizedString(@"ERROR_DESCRIPTION_MESSAGE_SEND_DISABLED_PREKEY_UPDATE_FAILURES",
|
2018-03-26 15:37:43 +02:00
|
|
|
@"Error message indicating that message send is disabled due to prekey update failures"));
|
2017-02-10 19:20:11 +01:00
|
|
|
}
|
|
|
|
|
2018-10-05 18:00:31 +02:00
|
|
|
NSError *OWSErrorMakeMessageSendFailedDueToBlockListError()
|
2017-04-01 22:47:16 +02:00
|
|
|
{
|
2017-04-05 23:34:47 +02:00
|
|
|
return OWSErrorWithCodeDescription(OWSErrorCodeMessageSendFailedToBlockList,
|
|
|
|
NSLocalizedString(@"ERROR_DESCRIPTION_MESSAGE_SEND_FAILED_DUE_TO_BLOCK_LIST",
|
2018-03-26 15:37:43 +02:00
|
|
|
@"Error message indicating that message send failed due to block list"));
|
2017-04-01 22:47:16 +02:00
|
|
|
}
|
|
|
|
|
2017-09-08 18:51:25 +02:00
|
|
|
NSError *OWSErrorMakeWriteAttachmentDataError()
|
|
|
|
{
|
|
|
|
return OWSErrorWithCodeDescription(OWSErrorCodeCouldNotWriteAttachmentData,
|
|
|
|
NSLocalizedString(@"ERROR_DESCRIPTION_MESSAGE_SEND_FAILED_DUE_TO_FAILED_ATTACHMENT_WRITE",
|
2018-03-26 15:37:43 +02:00
|
|
|
@"Error message indicating that message send failed due to failed attachment write"));
|
2017-09-08 18:51:25 +02:00
|
|
|
}
|
|
|
|
|
2016-08-26 16:01:53 +02:00
|
|
|
NS_ASSUME_NONNULL_END
|