Any software needs to handle errors, either triggered by the business rules that are defined or just to handle extraordinary circumstances that may appear. In RESTful APIs, we use status codes to tell our consumers when an error has occurred, but within our code, we need to handle those scenarios and ensure that they are handled gracefully. During this section, we will review some of the techniques that we could use to handle these situations.
Handling errors
Using controller advice
In our last example, we got an exception when our JSON was not formatted correctly. That exception was JsonParseException, and was not handled in any part of our code so Spring was automatically handling it for us and returning an error message...