在AspectJ中,我想吞下一个异常.
@Aspect
public class TestAspect {
@Pointcut("execution(public * *Throwable(..))")
void throwableMethod() {}
@AfterThrowing(pointcut = "throwableMethod()", throwing = "e")
public void swallowThrowable(Throwable e) throws Exception {
logger.debug(e.toString());
}
}
public class TestClass {
public void testThrowable() {
throw new Exception();
}
}
Run Code Online (Sandbox Code Playgroud)
上面,它没有吞下异常.testThrowable()的调用者仍然收到异常.我希望来电者不要收到例外.怎么办呢?谢谢.