I was able to get the @AfterThrowing work for my basic needs
@AfterThrowing(pointcut = "within(@custom.SomeAnnotation *) || @annotation(custom.SomeAnnotation) ", throwing = "ex")
public void intercept(Throwable ex) {
// do stuff
}
But when I try to read a field from the annotation I'm getting java.lang.IllegalArgumentException: error at ::0 inconsistent binding
I tried several approaches, the last one that I tried was:
@AfterThrowing(pointcut = "within(@custom.SomeAnnotation *) || @annotation(custom.SomeAnnotation) || @annotation(custom.SomeAnnotation(myProperty))", throwing = "ex", argNames = "ex, myProperty")
public void intercept(Throwable ex, String myProperty) {
// do stuff
}
Am I using the pointcut correctly?
I tried
@AfterThrowing(pointcut = "within(@custom.SomeAnnotation *) || " +
"@annotation(custom.SomeAnnotation) || " +
"@annotation(custom.SomeAnnotation) && args(myProperty))",
throwing = "ex", argNames = "ex, myProperty")
@AfterThrowing(pointcut = "@annotation(theAnnotation)",
throwing = "ex", argNames = "ex, theAnnotation")
public void intercept(Throwable ex, custom.SomeAnnotation theAnnotation)