You can use a common class annotated as @RestControllerAdvice
and declare exception handler methods for the exceptions that the business
logic might throw. For example, mapping InvalidInputException to the
HTTP response code UNPROCESSABLE_ENTITY might appear as follows: