added include-message property (commented out as the other properties), and updated deprecated getErrorAttributes method (caused not including the message property)
This commit is contained in:
parent
2838922e1b
commit
8f91e48a32
@ -2,6 +2,7 @@ package com.baeldung.web.config;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.web.error.ErrorAttributeOptions;
|
||||
import org.springframework.boot.web.servlet.error.DefaultErrorAttributes;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
@ -10,8 +11,8 @@ import org.springframework.web.context.request.WebRequest;
|
||||
public class MyCustomErrorAttributes extends DefaultErrorAttributes {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getErrorAttributes(WebRequest webRequest, boolean includeStackTrace) {
|
||||
Map<String, Object> errorAttributes = super.getErrorAttributes(webRequest, includeStackTrace);
|
||||
public Map<String, Object> getErrorAttributes(WebRequest webRequest, ErrorAttributeOptions options) {
|
||||
Map<String, Object> errorAttributes = super.getErrorAttributes(webRequest, options);
|
||||
errorAttributes.put("locale", webRequest.getLocale()
|
||||
.toString());
|
||||
errorAttributes.remove("error");
|
||||
|
@ -3,3 +3,4 @@ server.servlet.context-path=/spring-boot-rest
|
||||
### Spring Boot default error handling configurations
|
||||
#server.error.whitelabel.enabled=false
|
||||
#server.error.include-stacktrace=always
|
||||
#server.error.include-message=always
|
||||
|
Loading…
x
Reference in New Issue
Block a user