Hello I'm trying to throw custom Exceptions from my @Aspect, but no matter what exception I throw, my Aspect is throwing UndeclaredThrowableException,
My custom exception is
public class AuthorizationException extends RuntimeException {
public AuthorizationException(String msg) {
super(msg);
}
}
And my Aspect is
@Around("@annotation(MyCustomAnnotation)")
public Object validateAspect(ProceedingJoinPoint pjp throws Throwable {
// for testing purpose directly throwing
throw new AuthorizationException("My custom error);
}
And I'm supposed to get AuthorizationException but I'm getting UndeclaredThrowableException
I have tried directly throwing RuntimeError from the validateAspect method and changed throws Throwable to throws AuthorizationException but still same. Tried to catch it with Global Exception handler as well but the custom string message is always null.