spring-framework icon indicating copy to clipboard operation
spring-framework copied to clipboard

Provide options for external control over `ProblemDetail` properties for Spring web exceptions

Open rstoyanchev opened this issue 3 years ago • 0 comments

As part of #27052, each Spring web exception now implements ErrorResponse and exposes a ProblemDetail with details for the error response body. The detail field is typically set to a minimal message rather than the actual Exception message, to avoid exposing implementation specific details, and applications can extend ResponseEntityExceptionHandler to customize the details for each Spring web exception individually.

We should consider ways to customize the ProblemDetail for Spring web exceptions, and/or for any ErrorResponseException. One idea is to perform a lookup in a MessageSource using codes based on the exception name. ResponseStatusExceptionResolver does something similar and we could use this to derive type, title, and detail, including internationalized versions depending on the current locale.

One specific challenge will be the ability to parameterize messages with information from the exception.

rstoyanchev avatar Jul 13 '22 15:07 rstoyanchev