Exception: A good REST API should handle the exception properly and send the proper response to the user. The user should not be rendered with any unhandled exception. A REST API developer will have two requirements related to error handling.
@RestControllerAdvice is the combination of both @ControllerAdvice and @ResponseBody
The @ControllerAdvice annotation was first introduced in Spring 3.2.
We can use the @ControllerAdvice annotation for handling exceptions in the RESTful Services but we need to add @ResponseBody separately.
Note:
GlobalExceptionHandler was annotated with @ControllerAdvice, thus it is going to intercept exceptions from controllers accross the application.