This is an incomplete guide to the possible errors that may happen in your app. We have left some of them blank to prompt you to think about the errors that could occur as a client uses each endpoint that you have created.
Think about what could go wrong for each route, and the HTTP status code should be sent to the client in each case. For each thing that could go wrong, make a test with your expected status code and then make sure that possibility is handled.
Bear in mind, handling bad inputs from clients doesn't necessarily have to lead to a 4** status code. Handling can include using default behaviours or even ignoring parts of the request.
- 200 OK
- 201 Created
- 204 No Content
- 400 Bad Request
- 404 Not Found
- 405 Method Not Allowed
- 418 I'm a teapot
- 422 Unprocessable Entity
- 500 Internal Server Error
The Express Docs have a great section all about handling errors in Express.
- Status: ???
- Bad
review_id(e.g./dog) - Well formed
review_idthat doesn't exist in the database (e.g./999999)
- No
inc_voteson request body - Invalid
inc_votes(e.g.{ inc_votes : "cat" }) - Some other property on request body (e.g.
{ inc_votes : 1, name: 'Mitch' })
- Bad queries:
sort_bya column that doesn't existorder!== "asc" / "desc"categorythat is not in the databasecategorythat exists but does not have any reviews associated with it