Skip to content

Allow annotated methods on a Controller to be marked as exception handlers [SPR-4677] #9354

Closed
@spring-projects-issues

Description

@spring-projects-issues

Kenny MacLeod opened SPR-4677 and commented

In some cases, I would like to be able to more tightly bind a controller's exception handling to the controller itself. I am imagining an @ExceptionHandler annotation which can be added to a controller's methods, which would be invoked by the framework if the @RequestMapping-annotated handler methods throw an exception. These annotated methods would be used in preference to the context-wide ExceptionResolvers.

This would be particularly useful in controllers with multiple @RequestMapping methods, all of which have related exception handling requirements, but which are specific to the controller. Handling this sort of complex exception handling logic in a context-wide ExceptionResolver is decoupling things too much from the source of the exceptions.

Thoughts?


Affects: 2.5.3

Issue Links:

Referenced from: commits f09f4e8

Metadata

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