Class Throwables
java.lang.Object
org.keycloak.authorization.client.util.Throwables
- Author:
- Pedro Igor
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic RuntimeException
handleWrapException
(String message, Throwable cause) Handles ancause
and wraps it into aRuntimeException
.static <V> V
retryAndWrapExceptionIfNecessary
(Callable<V> callable, TokenCallable token, String message, Throwable cause) Retries the givencallable
after obtaining a freshtoken
from the server.
-
Constructor Details
-
Throwables
public Throwables()
-
-
Method Details
-
handleWrapException
Handles ancause
and wraps it into aRuntimeException
. The resulting cause contains more details in case the givencause
is of aHttpResponseException
.- Parameters:
callable
-pat
-message
- the messagecause
- the root cause- Returns:
- a
RuntimeException
wrapping the givencause
-
retryAndWrapExceptionIfNecessary
public static <V> V retryAndWrapExceptionIfNecessary(Callable<V> callable, TokenCallable token, String message, Throwable cause) throws RuntimeException Retries the given
callable
after obtaining a freshtoken
from the server. If the attempt to retry fails the exception is handled as defined byhandleWrapException(String, Throwable)
.A retry is only attempted in case the
cause
is aHttpResponseException
with a 403 status code. In some cases the session associated with the token is no longer valid and a new token must be issues.- Type Parameters:
V
- the result of the callable- Parameters:
callable
- the callable to retrytoken
- the tokenmessage
- the messagecause
- the cause- Returns:
- the result of the callable
- Throws:
RuntimeException
- in case the attempt to retry fails
-