Sane API errors
Description
Refactors the API to use exceptions instead of explicit error response generation.
Additions
- An abstract API exception class that contains its corresponding API error code
- 14 new exceptions implementing this class
- An exception handler that translates these exceptions into error responses
- Error codes now have a HTTP response code that should be returned if that error happens
- findExisting() functions in the repositories that throw an exception if the stored value could not be found
Changes
- API controllers use findExisting where possible
- Validation throws correct exceptions
- API fields are limited in length
- Some endpoints return different status codes in error conditions as these were incorrect previously
Test and Review
Resolves #176 (closed)
Resolves #94 (closed)
Improves #156
To be filled in by the reviewers
-
All of the methods are commented to expectation -
The methods are tested to satisfaction -
There are no unnecessary files present in the MR -
The continuous integration has no problems with the MR -
The MR is filled in as requested (including labels, milestones, and reviewers) -
The documentation is up-to-date -
All nullable parameters are marked as such
Edited by Tim van der Horst