in src/main/java/com/uber/cadence/internal/sync/SyncDecisionContext.java [193:242]
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 {
@SuppressWarnings("unchecked") // cc is just to have a place to put this annotation
Class<? extends Exception> cc = (Class<? extends Exception>) Class.forName(causeClassName);
causeClass = cc;
cause = getDataConverter().fromData(taskFailed.getDetails(), causeClass, causeClass);
} catch (Exception e) {
cause = e;
}
if (cause instanceof SimulatedTimeoutExceptionInternal) {
// This exception is thrown only in unit tests to mock the activity timeouts
SimulatedTimeoutExceptionInternal testTimeout = (SimulatedTimeoutExceptionInternal) cause;
return new ActivityTimeoutException(
taskFailed.getEventId(),
taskFailed.getActivityType(),
taskFailed.getActivityId(),
testTimeout.getTimeoutType(),
testTimeout.getDetails(),
getDataConverter());
}
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);
}