Skip to content

Support Predicate- based mappedHandler config in AbstractHandlerExceptionResolver #26772

Closed
@haupv1m

Description

Affects: Spring 5.3.5

I'm using Spring MVC framework with functional controller (HandlerFunction, HandlerFunctionFilter, are landed on Spring 5.2). While using it, I encountered problem with global exception capture.
If I use onError for handling exception, I still need to use @ControllerAdvice and @ErrorException for non-path exceptions (AccessDeniedException,NotFoundHandlerException, ...). This is inconsistency. After some research, I decide to use mappedHandlerClasses of ExceptionHandlerExceptionResolver to handle exception in functional controller. However, when enable setting mappedHandlerClasses, ExceptionHandlerExceptionResolver cannot handle non-path exceptions (AccessDeniedException,NotFoundHandlerException, ...).

In my opinion, ExceptionHandlerExceptionResolver should capture both HandlerMethod (annotation controller) and HandlerFunction (functional controller) in Spring MVC. Or another suggestion, it's mappedHandlerClasses should not effect to capability of handling HandlerMethod of ExceptionHandlerExceptionResolver.

Or is there any clever way to resolve this issue? Currently, I work around by creating another ExceptionHandlerExceptionResolver with mappedHandlerClasses for function controller exception handler, beside original ExceptionHandlerExceptionResolver.

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions