As of spring-projects/spring-framework#27052, Spring Framework provides support for the "Problem Details" RFC 7807. This is supported for both Spring MVC and Spring WebFlux, backed by ResponseEntityExceptionHandler.

We should introduce configuration properties (spring.mvc.problemdetails.enabled and spring.webflux.problemdetails.enabled) that contribute custom ResponseEntityExceptionHandler instances (annotated with @ControllerAdvice) so that ProblemDetail and related exceptions are handled properly and serialized as application/problem+json.

We should ensure that: * those properties are false by default, as this could be a breaking change for applications * those beans are not configured if a ResponseEntityExceptionHandler is already present in the context

Comment From: vpavic

Are there plans to make application/problem+json the default format for error responses in the future? I think something based on standards is always a more suitable default vs something non-standard.

However, it seems that such a change wouldn't be considered until 4.0 which is I assume years away.

Could you still consider changing the default for 3.0? It is a major release after all, and flipping one configuration property to restore previous behavior doesn't seem like a big deal.

Comment From: bclozel

There are no plans currently for this. The Problem Details support is completely new, and this also changes the response format. We would also probably need to deprecate/remove existing infrastructure such as ErrorController and ErrorAttributes. The current problem details feature supports internationalization, but HTML view rendering is not (like with Boot's error handling).

We're definitely considering this option and we will probably gradually improve and replace things during the 3.x timeline. We definitely need more feedback on this.