Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Error Handling

Patrick Holmes edited this page Sep 6, 2014 · 3 revisions

Platform considers two types of errors that can happen at runtime:

  • Business Errors: Errors that are thrown by app logic under certain conditions
  • Platform Errors: Errors that are thrown by platform components (e.g. DB)

These two types of errors are treated with the same Error handling strategy but the output is slightly different.

Business Errors

  • The same message that is sent to the caller is logged for analysis and correlation of events.
  • Have a human readable message and an Error code. The list of error codes specify an offset for each business Entity (for example 1000 for Devices, 2000 for Users, etc).
  • Also have an associated HTTP Status code following the standard convention. See table below for a list of common errors taking Device as example.
Entity Offset Err Code HTTP Status Description
General - 401 401 Not Authorized
Device 1 1400 400 Device has some invalid Data
Device 1 1404 404 Device Not Found
Device 1 1409 409 Device already exists
Device 1 1500 500 Error Saving Device

This list of Errors defines all the basic errors that are needed in a CRUD API. All entities should respect the same error codes adding the Offset.

Sample Error Response

HTTP 400 "Bad Request"
{
    "code":"1400",
    "message": "Device has some invalid Data,
    "errors" : [ "Id is badly formatted",
                 "Name length should be between 1 and 50",
                 "Date has invalid format"
                ]
}

Platform Errors

  • The real error code and message is logged for troubleshooting.
  • The error is masked with a generic code, and a generic message, indicating that something wrong ocurred on the platform.

Sample Error Response

HTTP 500 "Internal Server Error"
{
    "code":"500",
    "message": "Platform error ocurred"
}
Clone this wiki locally