OpenUpSA/wazimap-ng

API should always respond with json data

Opened this issue · 0 comments

As a User of the API when there is a problem with the response I want to get a JSON response and get the error code instead of a server error.

We need to always catch server errors for the API and respond with a valid response and JSON.
This is how an example error could look like

{
  "error": {
    "message": "what did go wrong",
    "type": "Type of Execption (if applicable)",
    "code": 500,
  }
}

The easiest way to get started on this is to pick one Endpoint. e.g.:
https://staging.wazimap-ng.openup.org.za/api/v1/profile/10977/points/themes/?format=json
This already returns a not found but not in the format listed above.

After that, we need be sure that all instances where we can get a server error are caught.