Skip to content

Error Handling in the app and error codes

Plsr edited this page Nov 17, 2014 · 8 revisions

For now, most errors triggered by thrid party software and frameworks are not handled directly. For the most part, it is checked if an error occurred and if so, I write my own, abstracted error. Like so:

NSData *data = [NSURLConnection sendSynchronousRequest:uploadRequest returningResponse:&response error:&HTTPError];
  // Check, if an error occurred during the HTTP-Request
  if(HTTPError != nil) {
    _screenshotURL = nil;
    // The custom error
    NSError *abstractedError = [NSError errorWithDomain:@"de.51seven.sssnap" code:517 userInfo:nil];
    [self triggerNotification:abstractedError];
}

##Error Domain
The errorDomain is constructed from a reverse-DNS style domain as seen in this SO thread. This makes sure, that the errorDomain is unique and does not override any other codes.

[NSError errorWithDomain:@"de.51seven.sssnap" code:517 userInfo:nil];

##Codes
This List contains all error codes used in the app with an explanation.

  • 404 - (HTTP Request Failed, Critical) This code is used when something did go wrong with the HTTP-Request. It does not tell, what exactly did go wrong but it shows that the Request was not finished properly and therefor it is likely that the retrieved screenshot URL (if any) is corrupted.
Clone this wiki locally