-
Notifications
You must be signed in to change notification settings - Fork 38.4k
@ExceptionHandler cannot handler java.lang.Error despite the annotation accept ? extends Throwable [SPR-11106] #15732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yuriy Nakonechnyy commented I highly agree with this issue - very often it makes a lot of sense to handle Errors e.g. for logging purposes and currently this is very big limitation of Spring which is very easy to change and fix (at least it looks like this). Please refer to the list of absolutely valid arguments for allowing this:
That's why I believe that this issue should be on the top of backlog for future releases due to relatelively easy implementation of it |
Yuriy Nakonechnyy commented Also in Affects Versions field of this issue only version 3.2.4 is mentioned, however this issue affects all versions up to version 4.2.5 - could someone please update this field or give me rights to update it? |
Juergen Hoeller commented This is indeed easy enough to address: We're wrapping such I've implemented this already and it works fine for me here. If I don't find any undesired side effects, I'll roll this into 4.3 RC1. |
Yuriy Nakonechnyy commented Hi Juergen! Thanks a lot for fantastically quick fix, that was incredibly fast :) Kind regards, |
Yuriy Nakonechnyy commented Just a short question: will implemented solution allow handling of classes that extend Throwable but not Error or Exception? |
Juergen Hoeller commented We can't propagate custom Throwables through the MVC processing contracts, so there is no need to explicitly handle them at the exception handler level. Technically, you'd get an |
Yuriy Nakonechnyy commented Ah, ok - throwing IllegalStateException for custom Throwables makes a lot of sense, thanks! |
Jiri Mikulasek opened SPR-11106 and commented
according to http://docs.spring.io/spring/docs/3.0.x/api/org/springframework/web/bind/annotation/ExceptionHandler.html
@Exceptionhandler
should allow to handle also Errors, however it can't, cause DispatcherServlet doesn't catch and deliver that to ExceptionHandlerAffects: 3.2.4, 4.2.5
Reference URL: http://stackoverflow.com/questions/8184593/why-error-is-not-getting-caught-even-when-explicitly-thrown/8212177#8212177
Issue Links:
@ExceptionHandler
should match cause as well (e.g. for exception thrown from argument formatter)2 votes, 4 watchers
The text was updated successfully, but these errors were encountered: