Review NSError usage.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-07-24 16:05:29 -04:00
parent 11f52757b2
commit b17a7c5751
3 changed files with 18 additions and 6 deletions

View File

@ -212,7 +212,7 @@ NS_ASSUME_NONNULL_BEGIN
NSHTTPURLResponse *response = (NSHTTPURLResponse *)task.response;
if (response.statusCode == 413) {
failure(OWSErrorWithCodeDescription(
OWSErrorCodeContactsUpdaterRateLimit, OWSSignalServiceKitErrorDomain));
OWSErrorCodeContactsUpdaterRateLimit, @"Contacts Intersection Rate Limit"));
} else {
failure(error);
}

View File

@ -88,8 +88,8 @@ uint32_t const OWSDevicePrimaryDeviceId = 1;
}
}
*success = NO;
*error = OWSErrorWithCodeDescription(OWSErrorCodeFailedToDecodeJson,
[NSString stringWithFormat:@"unable to decode date from %@", value]);
DDLogError(@"%@ unable to decode date from %@", self.tag, value);
*error = OWSErrorWithCodeDescription(OWSErrorCodeFailedToDecodeJson, @"Unable to decode date from %@");
return nil;
}
reverseBlock:^id(id value, BOOL *success, NSError **error) {
@ -101,8 +101,8 @@ uint32_t const OWSDevicePrimaryDeviceId = 1;
return result;
}
}
*error = OWSErrorWithCodeDescription(OWSErrorCodeFailedToEncodeJson,
[NSString stringWithFormat:@"unable to encode date from %@", value]);
DDLogError(@"%@ unable to encode date from %@", self.tag, value);
*error = OWSErrorWithCodeDescription(OWSErrorCodeFailedToEncodeJson, @"Unable to encode date");
*success = NO;
return nil;
}];
@ -178,6 +178,18 @@ uint32_t const OWSDevicePrimaryDeviceId = 1;
return self.deviceId == device.deviceId;
}
#pragma mark - Logging
+ (NSString *)tag
{
return [NSString stringWithFormat:@"[%@]", self.class];
}
- (NSString *)tag
{
return self.class.tag;
}
@end
NS_ASSUME_NONNULL_END

View File

@ -56,12 +56,12 @@ typedef NSDictionary<NSString *, id> *_Nonnull (^OWSProdAssertParametersBlock)()
#define kOWSAnalyticsParameterNSExceptionReason @"nsexception_reason"
#define kOWSAnalyticsParameterNSExceptionClassName @"nsexception_classname"
// We don't include the error description because it may have PII.
#define AnalyticsParametersFromNSError(__nserror) \
^{ \
return (@{ \
kOWSAnalyticsParameterNSErrorDomain : (__nserror.domain ?: @"unknown"), \
kOWSAnalyticsParameterNSErrorCode : @(__nserror.code), \
kOWSAnalyticsParameterNSErrorDescription : (__nserror.description ?: @"unknown"), \
}); \
}