I’m currently working through the Information & Security projects and on the Converter project I’ve run into something that I’ve been unsure of for a while and am hoping someone has some knowledge they can pass on.
In the Converter project you take user input in the form of a query string. There are a few ways that they can make a bad request:
- They don’t provide ?input=(VALUE_HERE)
- They provide a number that is not valid (a double fraction, a negative number).
- They provide and invalid unit (miles vs mi, kilometers vs km)
How would I decide how to handle these errors? What status codes? Do I throw errors? Do I return a json object?
A successful request will be returned a json object and a 200 status.