pacificclimate / climate-explorer-backend

3 stars 1 forks source link

Make API error messages visible to users #189

Open corviday opened 3 years ago

corviday commented 3 years ago

The APIs raise a variety of Exceptions with helpful texts, like this one in the data API, raised when a caller submits an unparseable time value. These messages are visible when running the backend on your workstation, which is helpful, but the live backend just displays a generic 500 message when you set the time paramter to "q".

Sending the error messages differently, or maybe setting up the security of the live servers differently might be helpful for users.

rod-glover commented 3 years ago

There ought to be a way to catch these errors and turn them into sensible HTTP error pages. I know I have done it for some Flask apps, but it's not anything particular to Flask. There are a variety of error codes we might return, several in the 4xx range for various conditions (e.g., 400 Bad Request, 404 Not Found). 500 is the last resort for an unanticipated error. Any error we raise ourselves should probably be turned into a 4xx.