Exclude one exception type from @ExceptionHandler
Hi,
we are using spring web mvc to, amongst other things, provide a restful API. Now often times it is mandated that all exceptions on the deployed web applications to be catched and a stack trace emailed to the developers.
In case of our API we implemented this by having all controllers extend a base controller that sports a generic exception handling method like this:
Code:
@ExceptionHandler
public ModelAndView handleException(HttpServletResponse response, Throwable exception) {
// log exception
// mail stacktrace
// set appropriate http response code if exception is known
// write short error message / description via MappingJacksonJsonView
...
}
There is one special case though. We use Jetty as a servlet container and in case of network timeouts, sudden browser closes etc. the exception "org.mortbay.jetty.EoFException" is thrown. There is obviously no way a webapp can handle this. Our best bet would be to re-throw the EoFException so that the servlet container can act accordingly. Unfortunately one can not simply re-throw from within an @ExceptionHandler method as the org.springframework.web.servlet.mvc.method.annotat ion.ExceptionHandlerExceptionResolver will see this as an invocation error of the handler method itself and catch the exception again.
Now my question is whether there is a feasible way if excluding just this exception type from the handler method at all?
Looking forward to your suggestions.
Greetings
a.e