Review NSError usage.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 11f52757b2
commit b17a7c5751

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

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

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

Loading…
Cancel
Save