Instrument errors in storage manager.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-07-21 17:12:00 -04:00
parent 19c0a7ad7c
commit 7da5df594f
2 changed files with 18 additions and 13 deletions

View file

@ -85,7 +85,11 @@ static NSString *keychainDBPassAccount = @"TSDatabasePass";
- (nullable Class)unarchiver:(NSKeyedUnarchiver *)unarchiver cannotDecodeObjectOfClassName:(NSString *)name originalClasses:(NSArray<NSString *> *)classNames
{
DDLogError(@"[OWSUnarchiverDelegate] Ignoring unknown class name: %@. Was the class definition deleted?", name);
OWSProdErrorWParams(@"storage_error_could_not_decode_class", ^{
return (@{
@"class_name" : name,
});
});
return [OWSUnknownObject class];
}
@ -180,13 +184,14 @@ static NSString *keychainDBPassAccount = @"TSDatabasePass";
return [unarchiver decodeObjectForKey:@"root"];
} @catch (NSException *exception) {
// Sync log in case we bail.
DDLogError(@"%@ Unarchiving key:%@ from collection:%@ and data %@ failed with error: %@",
self.tag,
key,
collection,
data,
exception.reason);
DDLogError(@"%@ Raising exception.", self.tag);
OWSProdErrorWParams(@"storage_error_deserialization", ^{
return (@{
@"collection" : collection,
kOWSProdAssertParameterNSExceptionName : exception.name,
kOWSProdAssertParameterNSExceptionReason : exception.reason,
kOWSProdAssertParameterNSExceptionClassName : NSStringFromClass([exception class]),
});
});
@throw exception;
}
};
@ -255,7 +260,7 @@ static NSString *keychainDBPassAccount = @"TSDatabasePass";
BOOL success = [ressourceURL setResourceValues:resourcesAttrs error:&error];
if (error || !success) {
DDLogError(@"Error while removing files from backup: %@", error.description);
OWSProdErrorWNSError(@"storage_error_file_protecion", error);
return;
}
}
@ -372,14 +377,14 @@ static NSString *keychainDBPassAccount = @"TSDatabasePass";
NSError *keySetError;
[SAMKeychain setPassword:newDBPassword forService:keychainService account:keychainDBPassAccount error:&keySetError];
if (keySetError) {
DDLogError(@"%@ Setting DB password failed with error: %@", self.tag, keySetError);
OWSProdErrorWNSError(@"storage_error_could_not_store_database_password", keySetError);
[self deletePasswordFromKeychain];
[NSException raise:TSStorageManagerExceptionNameDatabasePasswordUnwritable
format:@"Setting DB password failed with error: %@", keySetError];
} else {
DDLogError(@"Succesfully set new DB password.");
DDLogWarn(@"Succesfully set new DB password.");
}
return newDBPassword;

View file

@ -134,7 +134,7 @@ typedef NSDictionary<NSString *, id> *_Nonnull (^OWSProdAssertParametersBlock)()
#define OWSProdFailWNSError(__analyticsEventName, __nserror) \
{ \
DDLogError(@"%s:%d %@: %@", __PRETTY_FUNCTION__, __LINE__, __analyticsEventName, error.debugDescription); \
DDLogError(@"%s:%d %@: %@", __PRETTY_FUNCTION__, __LINE__, __analyticsEventName, __nserror.debugDescription); \
OWSProdFailWParams(__analyticsEventName, AnalyticsParametersFromNSError(__nserror)) \
}
@ -169,7 +169,7 @@ typedef NSDictionary<NSString *, id> *_Nonnull (^OWSProdAssertParametersBlock)()
#define OWSProdErrorWNSError(__analyticsEventName, __nserror) \
{ \
DDLogError(@"%s:%d %@: %@", __PRETTY_FUNCTION__, __LINE__, __analyticsEventName, error.debugDescription); \
DDLogError(@"%s:%d %@: %@", __PRETTY_FUNCTION__, __LINE__, __analyticsEventName, __nserror.debugDescription); \
OWSProdErrorWParams(__analyticsEventName, AnalyticsParametersFromNSError(__nserror)) \
}