use of com.uber.cadence.workflow.ActivityException in project cadence-client by uber-java.
the class SyncDecisionContext method mapActivityException.
private RuntimeException mapActivityException(Exception failure) {
if (failure == null) {
return null;
}
if (failure instanceof CancellationException) {
return (CancellationException) failure;
}
if (failure instanceof ActivityTaskFailedException) {
ActivityTaskFailedException taskFailed = (ActivityTaskFailedException) failure;
String causeClassName = taskFailed.getReason();
Class<? extends Exception> causeClass;
Exception cause;
try {
// cc is just to have a place to put this annotation
@SuppressWarnings("unchecked") Class<? extends Exception> cc = (Class<? extends Exception>) Class.forName(causeClassName);
causeClass = cc;
cause = getDataConverter().fromData(taskFailed.getDetails(), causeClass);
} catch (Exception e) {
cause = e;
}
return new ActivityFailureException(taskFailed.getEventId(), taskFailed.getActivityType(), taskFailed.getActivityId(), cause);
}
if (failure instanceof ActivityTaskTimeoutException) {
ActivityTaskTimeoutException timedOut = (ActivityTaskTimeoutException) failure;
return new ActivityTimeoutException(timedOut.getEventId(), timedOut.getActivityType(), timedOut.getActivityId(), timedOut.getTimeoutType(), timedOut.getDetails(), getDataConverter());
}
if (failure instanceof ActivityException) {
return (ActivityException) failure;
}
throw new IllegalArgumentException("Unexpected exception type: " + failure.getClass().getName(), failure);
}
Aggregations