Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
More informative debugging description for NSError
- (NSString *)debugDescription;
{
// Log the entirety of domain, code, userInfo for debugging.
// Operates recursively on underlying errors
NSMutableDictionary *dictionaryRep = [[self userInfo] mutableCopy];
[dictionaryRep setObject:[self domain]
forKey:@"domain"];
[dictionaryRep setObject:[NSNumber numberWithInteger:[self code]]
forKey:@"code"];
NSError *underlyingError = [[self userInfo] objectForKey:NSUnderlyingErrorKey];
NSString *underlyingErrorDescription = [underlyingError debugDescription];
if (underlyingErrorDescription)
{
[dictionaryRep setObject:underlyingErrorDescription
forKey:NSUnderlyingErrorKey];
}
// Finish up
NSString *result = [dictionaryRep description];
[dictionaryRep release];
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.