All Products
Search
Document Center

CloudFlow:Error handling

Last Updated:Mar 11, 2026

CloudFlow workflows can encounter expected or unexpected errors during execution. Error handling lets you recover gracefully by retrying the failed state or transitioning to a different state.

Two mechanisms work together:

  • Retry -- Automatically re-executes the failed state. Use this for transient errors such as throttling or temporary network issues.

  • Catch -- Transitions the workflow to a designated state when an error persists after all retries are exhausted.

CloudFlow always evaluates Retry first. Only after all retry attempts fail does it evaluate Catch.

Supported states

Add Retry and Catch fields to the following state types:

Retry

The Retry field accepts an array of retry rules. Each rule specifies which errors to match and how to retry.

ParameterTypeRequiredDescriptionExample
Errors[]stringYesError types to match. See Error types.["MyCustomError", "FnF.ALL"]
DescriptionstringYesA label for this retry rule.Retry policy #1
MaxAttemptsintYesMaximum number of retry attempts.3
IntervalSecondsintYesInitial interval between retries, in seconds. Maximum: 86,400 (24 hours).10
BackoffRatefloatNoMultiplier applied to IntervalSeconds after each attempt. When omitted, the interval stays constant.2
MaxBackoffSecondsintNoUpper bound for the computed retry interval, in seconds. Maximum: 86,400 (24 hours).30
Note

If multiple retry rules match the same error type, CloudFlow uses the first matching rule only. Place more specific error types before FnF.ALL so they are evaluated first.

Catch

The Catch field accepts an array of catch rules. When an error persists after all retries, CloudFlow evaluates catch rules in order and transitions to the Next state of the first matching rule.

ParameterTypeRequiredDescriptionExample
Errors[]stringYesError types to match. See Error types.["MyCustomException1", "FnF.ALL"]
DescriptionstringYesA label for this catch rule.Error catch rule #1
OutputConstructormap[string]anyNoConstructs custom output to pass as input to the Next state. See State OutputConstructor.See examples below.
NextstringYesThe state to transition to when the error is caught.my-next-state

OutputConstructor

When an error occurs, the failed state produces no output. Without OutputConstructor, the next state receives no input and the workflow cannot proceed meaningfully. Use OutputConstructor to build a structured output that the Next state can consume.

Note

If multiple catch rules match the same error type, CloudFlow uses the first matching rule only.

Error types

CloudFlow errors

These errors originate from the CloudFlow engine itself.

Error typeDescription
FnF.TaskTimeoutA single step in the workflow timed out.
FnF.TimeoutThe overall execution of a workflow timed out.
FnF.ALLA wildcard that catches all errors of CloudFlow. Place this as the last entry in your Retry or Catch array so that more specific rules are evaluated first.

Function Compute errors

These errors occur when CloudFlow invokes Function Compute. For error types related to other service integrations, see the corresponding service documentation.

Error typeDescription
FC.ResourceThrottledFunctions throttled due to high concurrency. All functions are limited by a total concurrency value. CloudFlow synchronously invokes Function Compute when CloudFlow executes Task states. The total concurrency value is the sum of the concurrency value in function invocations and the concurrency values of other invocation methods. You can request to modify the concurrency value of synchronous Function Compute invocations.
FC.ResourceExhaustedFunctions throttled due to insufficient resources. Contact us to resolve this.
FC.InternalServerErrorA system error in Function Compute. Re-execute the workflow.
FC.UnknownFunction Compute invoked the function, but an uncaught error occurred during execution. Sample error code: UnhandledInvocationError.
FC.{ErrorCode}Any other Function Compute error where {ErrorCode} is the specific error code. See Function Compute error codes.

Custom errors

Error typeDescription
{CustomError}Custom exception errors thrown by the callee, such as business logic errors in your functions.

Examples

All examples use a Task state that invokes a Function Compute function via FC:InvokeFunction. Replace the resourceArn placeholder with your actual function ARN:

acs:fc:<region-id>:<account-id>:functions/<function-name>/<version-or-alias>
PlaceholderDescriptionExample
<region-id>Region where the function residescn-hangzhou
<account-id>Alibaba Cloud account IDYour numeric account ID
<function-name>Function namemyfunction
<version-or-alias>Function version or aliasLATEST

For details on obtaining the function ARN, see Obtain the ARN of the function.

Basic retry and catch

This example retries MyCustomException1 up to 3 times at 2-second intervals. If all retries fail, the catch rule constructs custom error output and transitions to ErrorCatchExit.

Type: StateMachine
Name: ErrorHandleExample
SpecVersion: v1
Description: an example of basic error handling
StartAt: my-error-handle-example
States:
  - Type: Task
    Name: my-error-handle-example
    Action: FC:InvokeFunction
    TaskMode: RequestComplete
    Parameters:
      resourceArn: acs:fc:{regionId}:{accountId}:functions/myfunction/LATEST
      invocationType: Sync
      body: |
        xxx
    Retry:
      - Errors:
          - MyCustomException1
        Description: retry policy 1
        MaxAttempts: 3
        IntervalSeconds: 2
    Catch:
      - Errors:
          - MyCustomException1
        Description: catch policy 1
        OutputConstructor:
          ErrorCode: MyCustomException1
          ErrorMessage: MyCustomException1
        Next: ErrorCatchExit
    Next: SucceededExit
  - Type: Pass
    Name: ErrorCatchExit
    End: true
  - Type: Pass
    Name: SucceededExit
    End: true

What happens at runtime:

  1. The Task state runs FC:InvokeFunction.

  2. If MyCustomException1 occurs, CloudFlow retries up to 3 times, waiting 2 seconds between attempts.

  3. If all retries fail, the catch rule matches MyCustomException1, constructs output with ErrorCode and ErrorMessage, and transitions to ErrorCatchExit.

  4. If no error occurs, the workflow transitions to SucceededExit.

Note

MyCustomException1 is used as an example. You can modify the error name based on your business requirements.

Backoff retry

This example retries MyCustomException2 or MyCustomException3 up to 3 times with exponential backoff. The initial interval is 5 seconds and doubles after each attempt (backoff rate 2.0).

Type: StateMachine
Name: ErrorHandleExample
SpecVersion: v1
Description: an example of backoff error handling
StartAt: my-error-handle-example
States:
  - Type: Task
    Name: my-error-handle-example
    Action: FC:InvokeFunction
    TaskMode: RequestComplete
    Parameters:
      resourceArn: acs:fc:{regionId}:{accountId}:functions/myfunction/LATEST
      body: xxx
    Retry:
      - Errors:
          - MyCustomException2
          - MyCustomException3
        Description: retry policy 2
        MaxAttempts: 3
        IntervalSeconds: 5
        BackoffRate: 2.0
    Catch:
      - Errors:
          - MyCustomException2
          - MyCustomException3
        Description: catch policy 2
        Next: ErrorCatchExit
    Next: SucceededExit
  - Type: Pass
    Name: ErrorCatchExit
    End: true
  - Type: Pass
    Name: SucceededExit
    End: true

Retry timing:

The system attempts retries at intervals of 5, 10, 20, and 40 seconds based on the backoff rate 2.0.

If all retries fail, the catch rule transitions the workflow to ErrorCatchExit. No OutputConstructor is defined here, so the next state receives no custom error output.

Multiple retry and catch policies

This example combines three levels of error handling with different retry strategies:

  1. MyCustomException1 -- Retry up to 3 times at fixed 2-second intervals.

  2. MyCustomException2 and MyCustomException3 -- Retry up to 3 times with exponential backoff (initial: 5s, backoff rate: 2.0).

  3. FnF.ALL (catch-all) -- Retry up to 3 times with exponential backoff (initial: 5s, backoff rate: 2.0), capped at 30 seconds by MaxBackoffSeconds.

Type: StateMachine
Name: ErrorHandleExample
SpecVersion: v1
Description: an example of error handling
StartAt: my-error-handle-example
States:
  - Type: Task
    Name: my-error-handle-example
    Action: FC:InvokeFunction
    TaskMode: RequestComplete
    Parameters:
      resourceArn: acs:fc:{regionId}:{accountId}:functions/myfunction/LATEST
      body: xxx
    Retry:
      - Errors:
          - MyCustomException1
        Description: retry policy 1
        MaxAttempts: 3
        IntervalSeconds: 2
      - Errors:
          - MyCustomException2
          - MyCustomException3
        Description: retry policy 2
        MaxAttempts: 3
        IntervalSeconds: 5
        BackoffRate: 2.0
      - Errors:
          - FnF.ALL
        Description: retry policy 3
        MaxAttempts: 3
        IntervalSeconds: 5
        BackoffRate: 2.0
        MaxBackoffSeconds: 30
    Catch:
      - Errors:
          - MyCustomException1
        Description: catch policy 1
        OutputConstructor:
          ErrorCode: MyCustomException1
          ErrorMessage: MyCustomException1
        Next: ErrorCatchExit
      - Errors:
          - MyCustomException2
          - MyCustomException3
        Description: catch policy 2
        Next: ErrorCatchExit
      - Errors:
          - FnF.ALL
        Description: catch policy 3
        Next: ErrorCatchExit
    Next: SucceededExit
  - Type: Pass
    Name: ErrorCatchExit
    End: true
  - Type: Pass
    Name: SucceededExit
    End: true

How rule matching works:

CloudFlow evaluates retry and catch rules in the order they appear. For an error that does not match MyCustomException1, MyCustomException2, or MyCustomException3, the FnF.ALL catch-all rule handles it. The FnF.ALL retry uses MaxBackoffSeconds: 30 to cap the interval, so the system attempts retries at intervals of 5, 10, 20, and 30 seconds.

After all retry attempts are exhausted, the corresponding catch rule transitions the workflow to ErrorCatchExit.