Skip to content

Error Handling in the app and error codes

Plsr edited this page Nov 18, 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];

##Error Code Ethics
In general, we follow the convention that the higher the error code number, the more important it is. However, for sssnap this is slightly customised.
All Code below 100 are non-critical, meaning the program will be able to execute it's core functions despite these errors. In here, the higher the number, the more important the error.
All codes above 100 are critical, meaning the App is not able to execute properly. These codes are divided in different domains, rather similar to HTTP Error Codes.

*3xx - System Data Errors, covering everything where Data is not in the state as it should be (Parsing, URLs, ...)
*4xx - Network Errors, covering everything related to network requests (HTTP-Request, Auth, ...)

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

  • 050 - (A side operation could not be finished, Mediocre) An operation could not be finished. However, this operation does not influence the whole App and other core parts are still abled to work as they used to.
  • 300 - (Expected data was nil, Critical) Core data needed by the app to work as supposed was nil, therefor some operations cannot be executed.
  • 301 - (Parsing HTTP-Request response failed, Critical) There did something go wrong while parsing the HTTP-Request's data in a usable format, therefor the data most likely cannot be used properly.
  • 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