Skip to content

Conversation

baumeister25
Copy link
Collaborator

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.

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.
Fabian Baumeister added 3 commits November 4, 2022 16:16
- 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
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ baumeister25
❌ Fabian Baumeister


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.

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

Successfully merging this pull request may close these issues.

3 participants