Support Problem Details for HTTP APIs RFC7807 #3552
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces:
HttpProblem
class that represents the model ofRFC7807
problem details.It extends
RuntimeException
so it can be naturally thrown.It also provides handy static methods to instantiate a problem and a builder to make a fully packed instance.
ProblemDetailsErrorHandler
a global error handler aimed to make anything thrown from the app compliant withRFC7807
.It also contains special handling for some built-in exceptions to make the response more informative.
It always logs server errors(5xx) and can optionally log client errors (4xx) unless they are fully muted
I'm going to align our
ValidationResult
with RFC7807 in a separate PR. That's why both classes were placed in the core package nevertheless it may seem odd at the moment.If there are no critical comments I'll proceed to the documentation part.
@jknack pls take a look when you have a spare time