diff --git a/spring-boot-rest/README.md b/spring-boot-rest/README.md
index 0a8d13cf76..2b955ddc5b 100644
--- a/spring-boot-rest/README.md
+++ b/spring-boot-rest/README.md
@@ -1,3 +1,4 @@
Module for the articles that are part of the Spring REST E-book:
1. [Bootstrap a Web Application with Spring 5](https://www.baeldung.com/bootstraping-a-web-application-with-spring-and-java-based-configuration)
+2. [Error Handling for REST with Spring](http://www.baeldung.com/exception-handling-for-rest-with-spring)
diff --git a/spring-boot-rest/pom.xml b/spring-boot-rest/pom.xml
index baf9d35a09..3b8cf7e39e 100644
--- a/spring-boot-rest/pom.xml
+++ b/spring-boot-rest/pom.xml
@@ -20,12 +20,22 @@
org.springframework.boot
spring-boot-starter-web
+
+ com.fasterxml.jackson.dataformat
+ jackson-dataformat-xml
+
org.springframework.boot
spring-boot-starter-test
test
+
+ net.sourceforge.htmlunit
+ htmlunit
+ ${htmlunit.version}
+ test
+
@@ -39,5 +49,6 @@
com.baeldung.SpringBootRestApplication
+ 2.32
diff --git a/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/ErrorHandlingBootApplication.java b/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/ErrorHandlingBootApplication.java
new file mode 100644
index 0000000000..0885ecbbf7
--- /dev/null
+++ b/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/ErrorHandlingBootApplication.java
@@ -0,0 +1,15 @@
+package com.baeldung.errorhandling.boot;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.PropertySource;
+
+@SpringBootApplication
+@PropertySource("errorhandling-application.properties")
+public class ErrorHandlingBootApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ErrorHandlingBootApplication.class, args);
+ }
+
+}
diff --git a/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/configurations/MyCustomErrorAttributes.java b/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/configurations/MyCustomErrorAttributes.java
new file mode 100644
index 0000000000..e2c62cb907
--- /dev/null
+++ b/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/configurations/MyCustomErrorAttributes.java
@@ -0,0 +1,23 @@
+package com.baeldung.errorhandling.boot.configurations;
+
+import java.util.Map;
+
+import org.springframework.boot.web.servlet.error.DefaultErrorAttributes;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.WebRequest;
+
+@Component
+public class MyCustomErrorAttributes extends DefaultErrorAttributes {
+
+ @Override
+ public Map getErrorAttributes(WebRequest webRequest, boolean includeStackTrace) {
+ Map errorAttributes = super.getErrorAttributes(webRequest, includeStackTrace);
+ errorAttributes.put("locale", webRequest.getLocale()
+ .toString());
+ errorAttributes.remove("error");
+ errorAttributes.put("cause", errorAttributes.get("message"));
+ errorAttributes.remove("message");
+ errorAttributes.put("status", String.valueOf(errorAttributes.get("status")));
+ return errorAttributes;
+ }
+}
diff --git a/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/configurations/MyErrorController.java b/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/configurations/MyErrorController.java
new file mode 100644
index 0000000000..427a0b43d7
--- /dev/null
+++ b/spring-boot-rest/src/main/java/com/baeldung/errorhandling/boot/configurations/MyErrorController.java
@@ -0,0 +1,31 @@
+package com.baeldung.errorhandling.boot.configurations;
+
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.boot.autoconfigure.web.ErrorProperties;
+import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController;
+import org.springframework.boot.web.servlet.error.ErrorAttributes;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+@Component
+public class MyErrorController extends BasicErrorController {
+
+ public MyErrorController(ErrorAttributes errorAttributes) {
+ super(errorAttributes, new ErrorProperties());
+ }
+
+ @RequestMapping(produces = MediaType.APPLICATION_XML_VALUE)
+ public ResponseEntity