Created
March 12, 2011 14:37
-
-
Save mikeabdullah/867278 to your computer and use it in GitHub Desktop.
More informative debugging description for NSError
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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