Is it possible to wrap an exception into a custom exception in a throwsAdvice and throw back this custom exception? E.g I have a class A with a method called as func(). This func() throws different exceptions. I apply throws advice on this func where I wrap all these exceptions into MyOwnException class and throw back MyOwnException instead.
Is this possible, please advise.
I do not know much about Spring, but with AspectJ (also usable from within Spring apps) you can use an after() throwing
pointcut to catch an exception and wrap it into a RuntimeException.
Or, even better, you use the language feature called exception softening, see http://www.eclipse.org/aspectj/doc/next/progguide/semantics-declare.html#softened-exceptions and http://www.eclipse.org/aspectj/doc/next/adk15notebook/declare-soft.html.