use of com.uber.cadence.client.WorkflowFailureException in project cadence-client by uber-java.
the class WorkflowStubImpl method mapToWorkflowFailureException.
private <R> R mapToWorkflowFailureException(Exception failure, Class<R> returnType) {
failure = CheckedExceptionWrapper.unwrap(failure);
Class<Throwable> detailsClass;
if (failure instanceof WorkflowExecutionFailedException) {
WorkflowExecutionFailedException executionFailed = (WorkflowExecutionFailedException) failure;
try {
@SuppressWarnings("unchecked") Class<Throwable> dc = (Class<Throwable>) Class.forName(executionFailed.getReason());
detailsClass = dc;
} catch (Exception e) {
RuntimeException ee = new RuntimeException("Couldn't deserialize failure cause " + "as the reason field is expected to contain an exception class name", executionFailed);
throw new WorkflowFailureException(execution.get(), workflowType, executionFailed.getDecisionTaskCompletedEventId(), ee);
}
Throwable cause = dataConverter.fromData(executionFailed.getDetails(), detailsClass);
throw new WorkflowFailureException(execution.get(), workflowType, executionFailed.getDecisionTaskCompletedEventId(), cause);
} else if (failure instanceof EntityNotExistsError) {
throw new WorkflowNotFoundException(execution.get(), workflowType, failure.getMessage());
} else if (failure instanceof CancellationException) {
throw (CancellationException) failure;
} else if (failure instanceof WorkflowException) {
throw (WorkflowException) failure;
} else {
throw new WorkflowServiceException(execution.get(), workflowType, failure);
}
}
Aggregations