Uh oh!
There was an error while loading. Please reload this page.
Create an exceptionhandler using generic handling with OpenAPI - #5
Create an exceptionhandler using generic handling with OpenAPI#5baumeister25 wants to merge 4 commits into
Conversation
Exception Handling with REST always has a common problem. Somehow the exception needs to be mapped to an REST exception class. This often includes the status code of an exception, as well as further information. A naiv approach would be to add those details into the ExceptionClass, but this has two significant downsides. First of all the Rest specific information like the HTTP Status Code do not belong into the exception. They're part of the service layer. Second system specific exceptions do not contain those information. This approach here defines a generic mapper that can be controlled per exception class and that can use a behaviour per information on how to get the information. The mapper is part of the service layer and can easily be adjusted.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Rename packages - Rename classes - Remove unused classes
Added documentation of fields. Some are much easier now.
The Setters in the exceptionMappers directly put values into the ProblemDetailsTo. This can be considered a code smell, because the ProblemDetailsTo is changed hidden as a reference. Therefore, now Functions are used, that return the value that should be added to the ProblemDetailsTo. The map method created the ProblemDetailsTo and adds the values from the Functions.
CLAassistant
commented
Apr 11, 2025
Fabian Baumeister seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Exception Handling with REST always has a common problem. Somehow the exception needs to be mapped to an REST exception class.
This often includes the status code of an exception, as well as further information.
A naiv approach would be to add those details into the ExceptionClass, but this has two significant downsides. First of all the Rest specific information like the HTTP Status Code do not belong into the exception. They're part of the service layer.
Second system specific exceptions do not contain those information.
This approach here defines a generic mapper that can be controlled per exception class and that can use a behaviour per information on how to get the information.
The mapper is part of the service layer and can easily be adjusted.