Google+ Followers

Apr 17, 2013

SimpleMappingExceptionResolver ignore exception

Lately i wanted to ignore ClientAbortException that raised by tomcat (catalina), instead of having a lot of stacktrace relates to this exception to have some line of my own, custom line in the log like "Client abort exception." and that's it.

There are many ways to do it, one way is using the @ExceptionHandler annotation from spring within the controller. But i have found that this solution obliged me to do so in all the relevant handlers.

Better way i think, extending the SimpleMappingExceptionResolver , overrding resolveException method,
When the exception arrive, check if the simple class name of the class inside it contains "ClientAbortException".

Why this way ?
This way you keep your code decoupled from tomcat catalina , better practice i think.

hoped i helped.


1 comment: