How can I get my custom ResponseEntityExceptionHandler
or OAuth2ExceptionRenderer
to handle Exceptions raised by Spring security on a pure resource ser
Spring 3.0 Onwards,You can use @ControllerAdvice
(At Class Level) and extends org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
class from CustomGlobalExceptionHandler
@ExceptionHandler({com.test.CustomException1.class,com.test.CustomException2.class})
public final ResponseEntity customExceptionHandler(RuntimeException ex){
return new ResponseEntity(new CustomErrorMessage(false,ex.getMessage(),404),HttpStatus.BAD_REQUEST);
}