Search in sources :

Example 1 with WorkflowFailureException

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);
    }
}
Also used : WorkflowFailureException(com.uber.cadence.client.WorkflowFailureException) WorkflowNotFoundException(com.uber.cadence.client.WorkflowNotFoundException) DuplicateWorkflowException(com.uber.cadence.client.DuplicateWorkflowException) WorkflowException(com.uber.cadence.client.WorkflowException) WorkflowExecutionFailedException(com.uber.cadence.internal.common.WorkflowExecutionFailedException) DuplicateWorkflowException(com.uber.cadence.client.DuplicateWorkflowException) TimeoutException(java.util.concurrent.TimeoutException) WorkflowFailureException(com.uber.cadence.client.WorkflowFailureException) WorkflowNotFoundException(com.uber.cadence.client.WorkflowNotFoundException) WorkflowQueryException(com.uber.cadence.client.WorkflowQueryException) WorkflowException(com.uber.cadence.client.WorkflowException) CancellationException(java.util.concurrent.CancellationException) CompletionException(java.util.concurrent.CompletionException) WorkflowExecutionFailedException(com.uber.cadence.internal.common.WorkflowExecutionFailedException) WorkflowServiceException(com.uber.cadence.client.WorkflowServiceException) CancellationException(java.util.concurrent.CancellationException) EntityNotExistsError(com.uber.cadence.EntityNotExistsError) WorkflowServiceException(com.uber.cadence.client.WorkflowServiceException)

Aggregations

EntityNotExistsError (com.uber.cadence.EntityNotExistsError)1 DuplicateWorkflowException (com.uber.cadence.client.DuplicateWorkflowException)1 WorkflowException (com.uber.cadence.client.WorkflowException)1 WorkflowFailureException (com.uber.cadence.client.WorkflowFailureException)1 WorkflowNotFoundException (com.uber.cadence.client.WorkflowNotFoundException)1 WorkflowQueryException (com.uber.cadence.client.WorkflowQueryException)1 WorkflowServiceException (com.uber.cadence.client.WorkflowServiceException)1 WorkflowExecutionFailedException (com.uber.cadence.internal.common.WorkflowExecutionFailedException)1 CancellationException (java.util.concurrent.CancellationException)1 CompletionException (java.util.concurrent.CompletionException)1 TimeoutException (java.util.concurrent.TimeoutException)1