Instrument errors in app delegate.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-07-24 10:22:12 -04:00
parent 7da5df594f
commit 117bca7c48
3 changed files with 19 additions and 16 deletions

View File

@ -263,7 +263,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
DDLogError(@"%@ Failed to register for remote notifications with error %@", self.tag, error);
OWSProdErrorWNSError(@"app_delegate_error_failed_to_register_for_remote_notifications", error);
#ifdef DEBUG
DDLogWarn(@"%@ We're in debug mode. Faking success for remote registration with a fake push identifier", self.tag);
[PushManager.sharedManager.pushNotificationFutureSource trySetResult:[[NSMutableData dataWithLength:32] copy]];
@ -334,25 +334,24 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
NSError *typeError;
[url getResourceValue:&utiType forKey:NSURLTypeIdentifierKey error:&typeError];
if (typeError) {
DDLogError(
@"%@ Determining type of picked document at url: %@ failed with error: %@", self.tag, url, typeError);
OWSAssert(NO);
OWSFail(
@"%@ Determining type of picked document at url: %@ failed with error: %@", self.tag, url, typeError);
return NO;
}
if (!utiType) {
DDLogDebug(@"%@ falling back to default filetype for picked document at url: %@", self.tag, url);
OWSAssert(NO);
OWSFail(@"%@ falling back to default filetype for picked document at url: %@", self.tag, url);
utiType = (__bridge NSString *)kUTTypeData;
return NO;
}
NSNumber *isDirectory;
NSError *isDirectoryError;
[url getResourceValue:&isDirectory forKey:NSURLIsDirectoryKey error:&isDirectoryError];
if (isDirectoryError) {
DDLogError(@"%@ Determining if picked document at url: %@ was a directory failed with error: %@",
self.tag,
url,
isDirectoryError);
OWSAssert(NO);
OWSFail(@"%@ Determining if picked document at url: %@ was a directory failed with error: %@",
self.tag,
url,
isDirectoryError);
return NO;
} else if ([isDirectory boolValue]) {
DDLogInfo(@"%@ User picked directory at url: %@", self.tag, url);

View File

@ -43,6 +43,7 @@
NS_ASSUME_NONNULL_BEGIN
#define kOWSProdAssertParameterEnvelopeIsLegacy @"envelope_is_legacy"
#define kOWSProdAssertParameterEnvelopeHasContent @"has_content"
#define kOWSProdAssertParameterEnvelopeDescription @"envelope_description"
#define kOWSProdAssertParameterEnvelopeEncryptedLength @"encrypted_length"
@ -51,6 +52,7 @@ NS_ASSUME_NONNULL_BEGIN
NSData *__encryptedData = __envelope.hasContent ? __envelope.content : __envelope.legacyMessage; \
return (@{ \
kOWSProdAssertParameterEnvelopeIsLegacy : @(__envelope.hasLegacyMessage), \
kOWSProdAssertParameterEnvelopeHasContent : @(__envelope.hasContent), \
kOWSProdAssertParameterEnvelopeDescription : [self descriptionForEnvelopeType:__envelope], \
kOWSProdAssertParameterEnvelopeEncryptedLength : @(__encryptedData.length), \
}); \
@ -162,6 +164,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSString *)descriptionForEnvelopeType:(OWSSignalServiceProtosEnvelope *)envelope
{
OWSAssert(envelope != nil);
switch (envelope.type) {
case OWSSignalServiceProtosEnvelopeTypeReceipt:
return @"DeliveryReceipt";

View File

@ -117,18 +117,19 @@ typedef NSDictionary<NSString *, id> *_Nonnull (^OWSProdAssertParametersBlock)()
#define AnalyticsParametersFromNSError(__nserror) \
^{ \
return (@{ \
kOWSProdAssertParameterNSErrorDomain : __nserror.domain, \
kOWSProdAssertParameterNSErrorDomain : (__nserror.domain ?: @"unknown"), \
kOWSProdAssertParameterNSErrorCode : @(__nserror.code), \
kOWSProdAssertParameterNSErrorDescription : __nserror.description, \
kOWSProdAssertParameterNSErrorDescription : (__nserror.description ?: @"unknown"), \
}); \
}
#define AnalyticsParametersFromNSException(__exception) \
^{ \
return (@{ \
kOWSProdAssertParameterNSExceptionName : __exception.name, \
kOWSProdAssertParameterNSExceptionReason : __exception.reason, \
kOWSProdAssertParameterNSExceptionClassName : NSStringFromClass([__exception class]), \
kOWSProdAssertParameterNSExceptionName : (__exception.name ?: @"unknown"), \
kOWSProdAssertParameterNSExceptionReason : (__exception.reason ?: @"unknown"), \
kOWSProdAssertParameterNSExceptionClassName : \
(__exception ? NSStringFromClass([__exception class]) : @"unknown"), \
}); \
}