Managing errors in a RESTful API
In the previous recipe, we enhanced our RESTful API by using complex data structures. However, the application was not able to manage some common errors or return standard response codes. In this recipe, l we will enhance the previous RESTful API by managing common errors and returning consistent response codes following the standards.
Getting ready
You can use the project generated in the previous recipe or download the sample from the GitHub repository at https://github.com/PacktPublishing/Spring-Boot-3.0-Cookbook/.
You can find the code to start this exercise in the chapter1/recipe1-3/start
folder.
How to do it...
In this recipe, we will modify the RESTful API created in the previous recipe to handle the exceptions that can be raised by our application and we’ll return the most appropriate HTTP response code.
All content created in the following steps will be under the src/main/java/com/packt/football
folder or one of the...