Skip to content
Snippets Groups Projects

Sane API errors

Merged
Luc Everserequested to merge
sane-api-errors into development
All threads resolved!

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

Merge request reports

Pipeline #172992 passed

Pipeline passed for d95e7542 on sane-api-errors

Approval is optional
Ready to merge by members who can write to the target branch.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Erik Oudsen marked the checklist item All of the methods are commented to expectation as completed

    marked the checklist item All of the methods are commented to expectation as completed

  • Erik Oudsen marked the checklist item The methods are tested to satisfaction as completed

    marked the checklist item The methods are tested to satisfaction as completed

  • Erik Oudsen marked the checklist item There are no unnecessary files present in the MR as completed

    marked the checklist item There are no unnecessary files present in the MR as completed

  • Erik Oudsen marked the checklist item The continuous integration has no problems with the MR as completed

    marked the checklist item The continuous integration has no problems with the MR as completed

  • Erik Oudsen marked the checklist item The MR is filled in as requested (including labels, milestones, and reviewers) as completed

    marked the checklist item The MR is filled in as requested (including labels, milestones, and reviewers) as completed

  • Erik Oudsen marked the checklist item All nullable parameters are marked as such as completed

    marked the checklist item All nullable parameters are marked as such as completed

  • Erik Oudsen approved this merge request

    approved this merge request

  • Luc Everse resolved all discussions

    resolved all discussions

  • Tim van der Horst approved this merge request

    approved this merge request

  • Tim van der Horst marked the checklist item The documentation is up-to-date as completed

    marked the checklist item The documentation is up-to-date as completed

  • mentioned in commit 5e35bc84

  • unassigned @leverse

  • Please register or sign in to reply
    Loading