AdamVig / GoCoApi

API Server for the GoCoStudent app.
https://gocostudent.adamvig.com/api
GNU General Public License v3.0
0 stars 0 forks source link

Improve error reporting #14

Closed AdamVig closed 8 years ago

AdamVig commented 8 years ago

Instead of returning only a friendly error message as text/plain, return a JSON object containing the following fields:

{
  description: "Actual description of error message for debugging purposes"
  message: "User-facing message, ex: Something went wrong! 🆘 "
}

This change should also come with more descriptive use of error codes.

AdamVig commented 8 years ago

Restify comes with all of the HTTP status codes as error messages. See Restify Error Handling for more details. This could be a good way to throw errors in the app.

AdamVig commented 8 years ago

Restify error handling is excellent. Main improvements:

The format of the error response is now JSON, like the following:

{
    "code": "BadGatewayError", 
    "explanation": "Something went wrong! 🆘", 
    "message": "Could not find chapel credits in HTML."
}