-
Notifications
You must be signed in to change notification settings - Fork 40.9k
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
Render global errors as Problem Details #43850
Comments
Hi @bclozel , I would like to collaborate. Can I work on this issue? |
@kiruthiga1793 Thanks for the proposal but the issue is already assigned and I have a good chunk of changes ready. We're waiting for changes in Framework to complete this work. |
@bclozel Thanks for letting me know. Add me also next time if possible if the issue has some sub tasks. |
Hi Brian, in our company we implemented ErrorAttributes and ErrorView in a way that the Map structure resembled the JSON Problem structure for all spring framework exceptions and also added extension points for individual other exceptions. So I'm curious about the new improvement that come with Spring Framework and the way how exception handling will change in Spring Boot. |
@danielrohe Is your application enabling problem details support in Spring Boot with the Currently, exceptions that are not handled at this point escape to the global Spring Boot error handling and are rendered as traditional Spring Boot errors. The goal of this issue if to make those problem details responses. Note, Spring Framework must first extend its error rendering support to render HTML error pages spring-projects/spring-framework#34272. Hopefully once this is all done, you won't have to maintain this custom error handling setup anymore as this will all be done for you. |
Hi Brian, no, we didn't use Spring Framework's ProblemDetails support We implemented this approach of overwriting ErrorAttributes and ErrorView before Spring Framework supported Problem Details. This solution worked out quite well for all Spring Framework exceptions and also others like javax-validation's ConstraintViolationException for services that serve JSON and web (HTML) traffic. In addition we also have a Problem Details implementation at https://github.com/zalando/problem-spring-web that served pure backend services just serving JSON. For these services we can replace it with Spring Framework's Problem Details support as the responses are mostly similar. For the services that serve JSON and HTML we are using our implementation because the current Spring Framework does not support serving web (HTML) traffic. Therefore I'm curious what this new implementation will bring and whether its possible for users to utilize it for other framework exceptions like javax-validation's ConstraintViolationException. |
Spring Boot handles errors globally as JSON responses or HTML pages. This is powered by
ErrorController
andErrorAttributes
.Spring Framework added support for Problem Details and Spring Boot auto-configures this as of #32634.
This issue is about rendering global errors in the problem details format consistently, as well as providing a path forward to making this the default in the future. This means that
ErrorAttributes
would need to produce aProblemDetail
orErrorResponse
instead of aMap
. Also, we would probably need to revisit the backing infrastructure to better align with Framework. There are upcoming changes in Framework that could help us to improve the support and make it more lightweight, see spring-projects/spring-framework#34272.The text was updated successfully, but these errors were encountered: