Skip to content

Instantly share code, notes, and snippets.

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]
[dictionaryRep setObject:[NSNumber numberWithInteger:[self code]]
NSError *underlyingError = [[self userInfo] objectForKey:NSUnderlyingErrorKey];
NSString *underlyingErrorDescription = [underlyingError debugDescription];
if (underlyingErrorDescription)
[dictionaryRep setObject:underlyingErrorDescription
// 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.