ruuvi / ruuvitracker_server

RuuviTracker Server
https://ruuvi.com
BSD 2-Clause "Simplified" License
22 stars 7 forks source link

Add error responses when api request fail #10

Closed jsyrjala closed 12 years ago

jsyrjala commented 12 years ago

Catch exceptions and show 500 error when handling api requests fails. Currently connection is just closed.

jsyrjala commented 12 years ago

Make a JSON response with status code 500.

{"error": {
  "status-code": 500,   // same as in HTTP
  "message": "Internal server error",
  "timestamp": "2012-06-07T00:23:12.123+0000",   // makes log browsing easier
  "stacktrace": ".... this only in development mode ..."
}}
jsyrjala commented 12 years ago

Error messages look like this now:

    {"error":{"message":"resource not found"}}