Skip to content

FailureDetails.IsCausedBy throws #239

@andystaples

Description

@andystaples

When an activity function throws an exception, and it is caught by a custom retry handler in an orchestrator, the retryContext allows accessing the FailureDetails for analysis of the failure. However, attempting to use the FailureDetails.isCausedBy() method will never succeed, as it internally is implemented using Class.forName() which requires the fully-qualified exception class name but FailureDetails does not have this information serialized, just the simple exception class name.

Repro:

    @FunctionName("CustomRetryActivityFunction")
    public String customRetryActivityFunction(
            @DurableOrchestrationTrigger(name = "ctx") TaskOrchestrationContext ctx) {
        TaskOptions options = new TaskOptions(retryContext -> {
            FailureDetails lastFailure = retryContext.getLastFailure();
            if (lastFailure != null
                    && lastFailure.getErrorType().equals("OverflowException")
                    // This line should work, but doesn't
                    // && lastFailure.isCausedBy(InvalidOperationException.class)
                    && retryContext.getLastAttemptNumber() < 3) {
                return true;
            }
            return false;
        });
        return ctx.callActivity("RaiseComplexException", ctx.getInstanceId(), options, String.class).await();
    }
``

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Priority 1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions