From 8f91e48a32f64324aca7049d1069f0e2c64043a2 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Mon, 15 Feb 2021 17:57:21 -0300 Subject: [PATCH] added include-message property (commented out as the other properties), and updated deprecated getErrorAttributes method (caused not including the message property) --- .../com/baeldung/web/config/MyCustomErrorAttributes.java | 5 +++-- spring-boot-rest/src/main/resources/application.properties | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/config/MyCustomErrorAttributes.java b/spring-boot-rest/src/main/java/com/baeldung/web/config/MyCustomErrorAttributes.java index 1948d5552f..5e776c0e29 100644 --- a/spring-boot-rest/src/main/java/com/baeldung/web/config/MyCustomErrorAttributes.java +++ b/spring-boot-rest/src/main/java/com/baeldung/web/config/MyCustomErrorAttributes.java @@ -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 getErrorAttributes(WebRequest webRequest, boolean includeStackTrace) { - Map errorAttributes = super.getErrorAttributes(webRequest, includeStackTrace); + public Map getErrorAttributes(WebRequest webRequest, ErrorAttributeOptions options) { + Map errorAttributes = super.getErrorAttributes(webRequest, options); errorAttributes.put("locale", webRequest.getLocale() .toString()); errorAttributes.remove("error"); diff --git a/spring-boot-rest/src/main/resources/application.properties b/spring-boot-rest/src/main/resources/application.properties index 176deb4f49..5017eb2f0d 100644 --- a/spring-boot-rest/src/main/resources/application.properties +++ b/spring-boot-rest/src/main/resources/application.properties @@ -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