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:
Gerardo Roza 2021-02-15 17:57:21 -03:00
parent 2838922e1b
commit 8f91e48a32
2 changed files with 4 additions and 2 deletions

View File

@ -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");

View File

@ -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