I would like to treat my exceptions at a global level, but it seems that Spring MVC only provides a way to treat exceptions at Controller level with @ExceptionHandler annotation (for REST support with @ResponseBody annotation), which do not respect the DRY principle.
I read JAX-RS documentation and i found ExceptionMapper as the perfect response to my need… but i need an equivalent with Spring MVC 3.
Is there a solution?
Thanks.
I finally found the response by searching in Spring Javadoc.
In fact, i had to override the DefaultHandlerExceptionResolver.
Then you have to declare your new ExceptionResolver in your web application context.
So, when in your Controller you throw a MyNewException1, Spring MVC can handle it.