private static TimeoutExecutionException unwrapExceptionAsTimeoutException(Throwable cause, String messageFormat,
Object... parameters) {
Throwable current = cause;
while (current != null) {
if (current instanceof ExecutionException) {
return new TimeoutExecutionException(current, messageFormat, parameters);
}
current = current.getCause();
}
return new TimeoutExecutionException(cause, messageFormat, parameters);
}