I wrote an
@ExceptionHandler to send the exception in JSON for REST requests. However, due to the way Spring Security works,
AccessDeniedExceptions must not be handled.
If I simply rethrow an
AccessDeniedException in the handler, I get an
ERROR level logging saying:
Failed to invoke @ExceptionHandler method: SomeMethod() throws java.lang.Exception
org.springframework.security.access.AccessDeniedException: Access is denied
I cannot safely disable
ERROR level logging for the class logging it (
ExceptionHandlerExceptionResolver), but having these stacktrace is quite confusing for operations people.
Is there anyway to make
@ExceptionHandler not handle this specific exception?