If you want to create a generic exception message for all exceptions, we can add a method to RestResponseEntityExceptionHandler with the @ExceptionHandler(Exception.class) annotation.
The following code snippet shows how we can do this:
@ExceptionHandler(Exception.class)
public final ResponseEntity<ExceptionResponse> todoNotFound(Exception ex) {
//Customize and return the response
}
Any exception for which a custom exception handler is not defined will be handled by the previous method.