Created
June 18, 2014 12:15
-
-
Save mzaks/7c53b0df161f62eac535 to your computer and use it in GitHub Desktop.
OMDeffered fail with result category
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
@implementation OMDeferred (FailWithResult) | |
-(void)fail:(NSError *)error withResult:(id)result{ | |
NSAssert(error, @"Error object should not be nil"); | |
NSAssert(error.domain, @"Error object should have a domain"); | |
if(result){ | |
NSMutableDictionary *newUserInfo = [NSMutableDictionary dictionaryWithDictionary:error.userInfo]; | |
newUserInfo[ERROR_RESULT_KEY] = result; | |
error = [NSError errorWithDomain:error.domain code:error.code userInfo:newUserInfo.copy]; | |
} | |
[self fail:error]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment