Response Entity Exception Handling
mark the class with
ControllerAdvice
andResponseStatus
The class should extend
ResponseEntityExceptionHandler
Annotate the member function with
@ExceptionHandler(T.class)
where T is the custom exception classMake sure to include
String message
andInteger statusCode
in the custom exception.Example
Last updated