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

[ENHANCEMENT]: Refactor Exception Handling to Use specific Exception Types for Better Error differentiation. #1104

Open
jessevz opened this issue Oct 14, 2024 · 1 comment
Assignees
Labels
enhancement Enhancement of existing features / Small addition

Comments

@jessevz
Copy link
Contributor

jessevz commented Oct 14, 2024

Description

Currently the project only makes use of HTException as a very general exception for all error cases. This makes it challenging to handle different errors appropriately. Especially if we want to adhere to the JSON API standard it is helpful if more specific Exceptions get throwed so that the API can catch these specific exceptions and respond with appropriate HTTP status codes and responses.

Tasks:

  • Define and implement specific exception classes for common error scenario ex: conflict, field missing ....
  • Refactor service and logic layers to throw the new exceptions
  • Update the new API to catch specific exceptions and return the proper HTTP responses
  • Add documentation for the new exception handling
@jessevz jessevz added the enhancement Enhancement of existing features / Small addition label Oct 14, 2024
@ObsidianOracle ObsidianOracle moved this to 📝 Todo in 🚀 1.0 Release Nov 6, 2024
@gluafamichl
Copy link
Contributor

We usually define a base exception class, e.g. ApplicationException and derive all other exceptions from this base class, lets say DBFieldErrorException, InvalidTypeException and so on. Each exception contains its own error message and/or a status code.

The surrounding API does not know, which exact exceptions could be thrown, it always catches ApplicationExcetion, but gets the error message and error code from the real exception class.

Maybe we could define a similar exception system, just share your thoughts ;-)

@gluafamichl gluafamichl moved this from 📝 Todo to ⏳🙄 Waiting for in 🍺 Sprint November '24 Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of existing features / Small addition
Projects
Status: ⏳🙄 Waiting for
Status: 📝 Todo
Development

No branches or pull requests

2 participants