Created
March 4, 2012 14:51
-
-
Save webdevotion/1973361 to your computer and use it in GitHub Desktop.
error handling
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
- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError | |
{ | |
todoItems = [NSPropertyListSerialization propertyListWithData:data options:NSPropertyListMutableContainers format:NULL error:outError]; | |
BOOL errorFound = todoItems == nil; | |
if (errorFound) | |
{ | |
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; | |
[userInfo setValue:@"Custom Error Description" forKey:NSLocalizedDescriptionKey]; | |
[userInfo setValue:@"Custom Failure Reason" forKey:NSLocalizedFailureReasonErrorKey]; | |
[userInfo setValue:@"Custom Recovery Suggestion" forKey:NSLocalizedRecoverySuggestionErrorKey]; | |
NSError *myError = | |
[NSError errorWithDomain:@"My Custom Domain" code:41 userInfo:userInfo]; | |
[NSApp presentError:myError]; | |
*outError = [NSError errorWithDomain:NSCocoaErrorDomain code:NSUserCancelledError userInfo:nil]; | |
} | |
return !errorFound; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment