Currently it is possible to create "controller" style exception handler using @ControllerAdvice and @ExceptionHandler annotations and then make it central exception handler for application and also make it handle security exceptions with:
authenticationEntryPoint = AuthenticationEntryPoint { request, response, exception ->
handlerExceptionResolver.resolveException(request, response, null, exception)
}
accessDeniedHandler = AccessDeniedHandler { request, response, exception ->
handlerExceptionResolver.resolveException(request, response, null, exception)
}
However if you create "router" style exception handler (in WebMvc functional router with onError), it won't handle security exceptions with above configuration, nor will it handle resource not found exceptions from dispatcher servlet.
"controller" style exception handler will handle correctly all of these.
It is unfortunate that application that is solely router based is forced to have one style of exception handlers for it's routers and other style for security and "general" exceptions.
It should be possible to make router style exception handlers handle these general exceptions.
Meanwhile is there anyway to achieve this with some workaround?
Currently it is possible to create "controller" style exception handler using
@ControllerAdviceand@ExceptionHandlerannotations and then make it central exception handler for application and also make it handle security exceptions with:However if you create "router" style exception handler (in WebMvc functional router with
onError), it won't handle security exceptions with above configuration, nor will it handle resource not found exceptions from dispatcher servlet."controller" style exception handler will handle correctly all of these.
It is unfortunate that application that is solely router based is forced to have one style of exception handlers for it's routers and other style for security and "general" exceptions.
It should be possible to make router style exception handlers handle these general exceptions.
Meanwhile is there anyway to achieve this with some workaround?