Pick status code from ErrorResponse
interfaces
#942
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.
Unhandled exceptions that extend spring-boot's
ErrorResponse
have a status code defined and we should use that instead of forcing it to be500
Description
Adding
problem-spring-web
to your project has a consequence of turning exceptions which haven't been explicitly handled into500
s. While at face value this may seem like a reasonable default behaviour, one should take into consideration that spring-boot can throw errors internally which have status codes attached to them, so it's only fair thatproblem
should listen to those and pass them forwards.Motivation and Context
Adding
problem-spring-web
to a bare spring-boot project and extending fromProblemHandling
causes errors to turn into500
s. For example, calling an endpoint that doesn't exist results in500 Resource not found
instead of404 Resource not found
which is the default and expected behaviour.Types of changes
Checklist: