Skip to content

Latest commit

 

History

History
74 lines (53 loc) · 2.67 KB

error-handling.md

File metadata and controls

74 lines (53 loc) · 2.67 KB

Error Handling

This section shows you how to handle all kinds of errors when loading a table view

  • Internet connection error
  • Server error
  • Request error
  • JSON parsing error
  • Data-binding error
  • Validation error

How to handle table view errors?

ALTableView has a new delegate designed for status update <ALTableViewLoadingDelegate>.

The delegate provides two optional protocols for will/did load.

Objective-C Swift

func willLoadTableView(with request: URLRequest!) -> URLRequest!

func didLoadTableViewWithError(_ error: Error!)


- (NSURLRequest *)willLoadTableViewWithRequest:(NSURLRequest *)request;
  • (void)didLoadTableViewWithError:(NSError *)error;

Set loadingDelegate to one of your objects, then implement any of those methods accordingly.

Objective-C Swift

tableView.loadingDelegate = self

self.tableView.loadingDelegate = self;

If the error object is empty, then no error occurred.

Otherwise, you can check the error.statusCode or print out the error.localizedString to check the error details.


Error codes

Abstract Layer abides by HTTP status code:

  • Code 200: Success
  • Code 204: No Content (Empty response)
  • Code 400: Bad Request (Error with URL, HTTP method, or parameters)
  • Code 401: Unauthorized
  • Code 404: Not found (API doesn't exist)
  • Code 500: Server internal error