I am invoking a method from within an AOP (Spring) (Around advice).
Once the method returns i do some checking on the object and if i am not happy with the results i throw an exception (my own). However, when the aspect returns, instead of my exception i get an “UndeclaredThrowableException”
Any idea how to handle this?
I am invoking a method from within an AOP (Spring) (Around advice). Once the
Share
If you look at the documentation for
UndeclaredThrowableExceptionit mentions that this occurs due to the the fact that a checked exception is being thrown that is not expected by the method signature that you are using as a joinpoint.The way it appears you should deal with this situation is to make the exception that you are throwing a Runtime exception (extends Runtime Exception).
Its worth noting you seem to be able to access the original exception like so:
However I reckon that is the wrong way to go about solving the problem you are having.