我有自己的异常“MyOwnException”并从我的服务类中抛出此异常
public void service() throws MyOwnException
{
// some code
}
现在我想在建议中捕获 MyOwnException 并重新抛出一个全新的异常
public class SimpleThrowsAdvice implements ThrowsAdvice {
public void afterThrowing(Method method, Object[] args, Object target,
MyOwnException ex) throws Throwable {
throw new Exception("new Description",ex);
}
}
现在,我如何捕获上述 Advice SimpleThrowsAdvice
中重新抛出的 Exception
?
最佳答案
您应该使用周围建议来做到这一点。看到这里Spring AOP AfterThrowing vs. Around Advice
关于java - 如何捕获 Spring AOP Advice 抛出的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3393024/