Skip to content

Instantly share code, notes, and snippets.

@mikeash
Created January 15, 2011 16:08
Show Gist options
  • Save mikeash/781000 to your computer and use it in GitHub Desktop.
Save mikeash/781000 to your computer and use it in GitHub Desktop.
dirty error example
- (id)fooWithError: (NSError **)outError
{
id obj = [self barWithThing: @"thing" error: outError];
if(!obj)
obj = [self quuxWithThing: @"thing" error: outError];
return obj;
}
@Orion98MC
Copy link

- (id)fooWithError: (NSError **)outError
{
  NSError *innerError;
  id obj = [self barWithThing: @"thing" error: innerError];
  if(!obj) {
    innerError = nil;
    obj = [self quuxWithThing: @"thing" error: innerError];
  }
  if (!obj) outError = &innerError;
  return obj;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment