-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Allow for external customization and i8n of the "detail" of an RFC 7807 response #28814
Comments
Expand the documentation for error responses and add details on using a MessageSource to customize and internationalize error details. See gh-28814
ProblemDetail
properties for Spring web exceptions
This is now largely done. Check the updated documentation section on Error Responses section and the sub-section on customization and internationalization. |
Hi @rstoyanchev
Instead what I thought I had to do was something like this
This feels quite awkward and in finally getting to that solution I stumbled across an NPE here when I did Does Also the current implementation essentially only supports customizing the message detail via the message source for |
@biergit, thanks for taking a look and for the feedback. Generally, you don't need to extend I've created #29384 to make an improvement, and there is a specific proposal. Please, take a look and let's continue the discussion there. As for |
The link above is broken |
After #27052, each Spring MVC / WebFlux exception implements
ErrorResponse
and exposesProblemDetail
for the response body. By default, the "detail" field is set to a minimal message (and not than the actual Exception message), to avoid leaking implementation details. An application can extendResponseEntityExceptionHandler
and override protected methods customize the details for each exception.We should consider a way to allow customization of the error "detail" for each Spring MVC and WebFlux exception, as well as for any
ErrorResponseException
, for example by performing a lookup in aMessageSource
with a message code derived from the exception name. That would allow an application to customize and internationalize exception messages through property files. This is already supported for@ResponseStatus
exceptions, and we could support the same forErrorResponse
exceptions.One specific challenge will be the ability to parameterize messages with information that is specific to each exception.
The text was updated successfully, but these errors were encountered: