Skip to content

Instantly share code, notes, and snippets.

@mzaks
Created June 18, 2014 12:15
Show Gist options
  • Save mzaks/7c53b0df161f62eac535 to your computer and use it in GitHub Desktop.
Save mzaks/7c53b0df161f62eac535 to your computer and use it in GitHub Desktop.
OMDeffered fail with result category
@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