Why exception handler doesn't detect error in spring mvc

I want to catch an error in springMVC3 using an exception handler. I annotated the exception. I can catch a throw and any exception. But when I tried with Error.It does not catch exception.Any idea why its so. below code throws exceptions

ExceptionHandler(InvalidDataException.class)
public ModelMap handleException(InvalidDataException ex) {
    logger.debug("exception catched  :" + ex);

    return new ModelMap();

}

But do not catch below.

@ExceptionHandler(Error.class)
public ModelMap handleException(Error ex) {
    logger.debug("exception catched  :" + ex);

    return new ModelMap();

}
+5
source share
3 answers

, Error, Throwable, Exception. , , "@ExceptionHandler" "handleException()" "", "InvalidDataException" , .

+3

Even I also faced the same problem, I think @ExceptionHandler can only deal with exceptions, not throwable and errors Follow the link: ExceptionHandler does not work with Throwable

0
source

All Articles