Search in sources :

Example 1 with ActivityTaskTimeoutException

use of com.uber.cadence.internal.replay.ActivityTaskTimeoutException 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);
}
Also used : ActivityFailureException(com.uber.cadence.workflow.ActivityFailureException) ActivityTimeoutException(com.uber.cadence.workflow.ActivityTimeoutException) CancellationException(java.util.concurrent.CancellationException) ActivityException(com.uber.cadence.workflow.ActivityException) ActivityTaskFailedException(com.uber.cadence.internal.replay.ActivityTaskFailedException) ActivityTimeoutException(com.uber.cadence.workflow.ActivityTimeoutException) ChildWorkflowTaskFailedException(com.uber.cadence.internal.replay.ChildWorkflowTaskFailedException) ActivityTaskTimeoutException(com.uber.cadence.internal.replay.ActivityTaskTimeoutException) ActivityTaskFailedException(com.uber.cadence.internal.replay.ActivityTaskFailedException) ChildWorkflowFailureException(com.uber.cadence.workflow.ChildWorkflowFailureException) CancellationException(java.util.concurrent.CancellationException) ChildWorkflowException(com.uber.cadence.workflow.ChildWorkflowException) ActivityFailureException(com.uber.cadence.workflow.ActivityFailureException) SignalExternalWorkflowException(com.uber.cadence.workflow.SignalExternalWorkflowException) ActivityException(com.uber.cadence.workflow.ActivityException) ActivityTaskTimeoutException(com.uber.cadence.internal.replay.ActivityTaskTimeoutException)

Aggregations

ActivityTaskFailedException (com.uber.cadence.internal.replay.ActivityTaskFailedException)1 ActivityTaskTimeoutException (com.uber.cadence.internal.replay.ActivityTaskTimeoutException)1 ChildWorkflowTaskFailedException (com.uber.cadence.internal.replay.ChildWorkflowTaskFailedException)1 ActivityException (com.uber.cadence.workflow.ActivityException)1 ActivityFailureException (com.uber.cadence.workflow.ActivityFailureException)1 ActivityTimeoutException (com.uber.cadence.workflow.ActivityTimeoutException)1 ChildWorkflowException (com.uber.cadence.workflow.ChildWorkflowException)1 ChildWorkflowFailureException (com.uber.cadence.workflow.ChildWorkflowFailureException)1 SignalExternalWorkflowException (com.uber.cadence.workflow.SignalExternalWorkflowException)1 CancellationException (java.util.concurrent.CancellationException)1