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..f05d242072 100644
--- a/spring-boot-rest/pom.xml
+++ b/spring-boot-rest/pom.xml
@@ -20,12 +20,30 @@
org.springframework.boot
spring-boot-starter-web
+
+ com.fasterxml.jackson.dataformat
+ jackson-dataformat-xml
+
+
+ org.hibernate
+ hibernate-entitymanager
+
+
+ org.springframework
+ spring-jdbc
+
org.springframework.boot
spring-boot-starter-test
test
+
+ net.sourceforge.htmlunit
+ htmlunit
+ ${htmlunit.version}
+ test
+
@@ -39,5 +57,6 @@
com.baeldung.SpringBootRestApplication
+ 2.32
diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/SpringBootRestApplication.java b/spring-boot-rest/src/main/java/com/baeldung/web/SpringBootRestApplication.java
index 62aae7619d..c945b20aa1 100644
--- a/spring-boot-rest/src/main/java/com/baeldung/web/SpringBootRestApplication.java
+++ b/spring-boot-rest/src/main/java/com/baeldung/web/SpringBootRestApplication.java
@@ -1,4 +1,4 @@
-package com.baeldung;
+package com.baeldung.web;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
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
new file mode 100644
index 0000000000..1948d5552f
--- /dev/null
+++ b/spring-boot-rest/src/main/java/com/baeldung/web/config/MyCustomErrorAttributes.java
@@ -0,0 +1,23 @@
+package com.baeldung.web.config;
+
+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/web/config/MyErrorController.java b/spring-boot-rest/src/main/java/com/baeldung/web/config/MyErrorController.java
new file mode 100644
index 0000000000..e3716ec113
--- /dev/null
+++ b/spring-boot-rest/src/main/java/com/baeldung/web/config/MyErrorController.java
@@ -0,0 +1,31 @@
+package com.baeldung.web.config;
+
+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