Description
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:
- Annotation for exception handling inside annotation based Controllers [SPR-5565] #10236 Annotation for exception handling inside annotation based Controllers ("is duplicated by")
- Portlet-version of @ExceptionHandler [SPR-5633] #10304 Portlet-version of
@ExceptionHandler
Referenced from: commits f09f4e8