Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common Exception Hierarchy #23

Open
vaclavHala opened this issue May 29, 2016 · 0 comments
Open

Common Exception Hierarchy #23

vaclavHala opened this issue May 29, 2016 · 0 comments

Comments

@vaclavHala
Copy link
Owner

vaclavHala commented May 29, 2016

All of these can be found in cz.muni.fi.pv243.spatialtracker.common together with a corresponding ExceptionMapper.

  • SpatialTrackerException
    • checked, abstract, all other exceptions extend this
  • IllegalOperationException
    • Maps to HTTP 403
    • Thrown when the target of a operation exists and caller is authorized to perform operation of this type, however the context, parameterization etc. of the particular invocation are invalid.
  • InvalidInputException
    • Maps to HTTP 400
    • Thrown when input received from user is incomplete, contains invalid values etc. This exception contains collection of all errors found in the users input .
    • Contains collection of all errors that were found in the input (email taken, too short password, ...)
  • NotFoundException
    • Maps to HTTP 404
    • Thrown when the resource user wishes to access does not exist.
    • Contains identifier of the object/resource that was not found
  • UnauthorizedException
    • Maps to HTTP 401
    • Thrown when a user tries to perform an action without being authorized to.
  • BackendServiceException
    • Maps to HTTP 500
    • Thrown when one of depended-on services is unavailable, returns unexpected values or reports its own internal error.

All of the exceptions are checked so they have to at least be declared and rethrown everywhere to make it obvious what are all the things that can go wrong. Please either use one of the above or add new subclass to the list and use that. Do not throw unchecked exceptions from top level public service methods.

Any of these can be thrown from outward facing REST endpoint and will be mapped correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant