ResponseStatusException reason as message code for ProblemDetail
See gh-30300
This commit is contained in:
committed by
rstoyanchev
parent
6697f01d05
commit
a3532bfccc
@@ -40,6 +40,7 @@ import org.springframework.lang.Nullable;
|
||||
* {@code @RestController} or {@code RestControllerAdvice} class.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Yanming Zhou
|
||||
* @since 6.0
|
||||
* @see ErrorResponseException
|
||||
*/
|
||||
@@ -142,6 +143,14 @@ public interface ErrorResponse {
|
||||
if (detail != null) {
|
||||
getBody().setDetail(detail);
|
||||
}
|
||||
else {
|
||||
// detail from ResponseStatusException reason may be message code
|
||||
detail = getBody().getDetail();
|
||||
if (detail != null) {
|
||||
detail = messageSource.getMessage(detail, null, detail, locale);
|
||||
getBody().setDetail(detail);
|
||||
}
|
||||
}
|
||||
String title = messageSource.getMessage(getTitleMessageCode(), null, null, locale);
|
||||
if (title != null) {
|
||||
getBody().setTitle(title);
|
||||
|
||||
Reference in New Issue
Block a user