I want to use an interceptor for my bean that checks the validity of a given connection token.
If the connection is invalid, I want to throw a specific exception, if the connection has expired, I want to send another (TokenExpiredException, something like this). These Exceptions are included in the interface provided to the client.
@AroundInvoke
public Object checkParams(InvocationContext ctx) throws TokenExpiredException, Exception{
throw new TokenExpiredException();
}
From what I tried, throwing such a specific exception into Interceptor results UndeclaredThrowableExceptionin client-side. Although this exception includes a reference to the reason, it is not ideal and cannot be considered with regular catch clauses.
What is the correct way to declare different types of exceptions with interceptors?