All Products
Search
Document Center

CloudFlow:Fail steps

Last Updated:Oct 30, 2023

This topic describes fail steps and related examples.

Overview

A fail step ends a series of steps in advance, similar to raise and throw in programming languages. After a fail step is executed in a flow, steps following the fail step will not be executed and the parent step of the fail step also fails. This continues until the flow execution fails.

A fail step contains the following attributes:

  • type: Required. The step type. The value fail indicates that the step is a fail step.
  • name: Required. The step name.
  • error: Optional. The error type.
  • cause: Optional. The cause of the error.
  • inputMappings: Optional. The input mappings.
  • outputMappings: Optional. The output mappings.

Examples

The following sample flow ends in advance by using a fail step.

  • If the value of status in the input is ready, the pass1 and final steps of the first choice are executed in sequence.
  • If the value of status in the input is failed, the goto instructions of the second choice are executed, the choice step ends, and the handle_failure step is executed. The handle_failure step is a fail step. Therefore, after it is executed, the final step will not be executed.
  • If the input does not contain status or the value of status is neither ready nor failed, the default choice is executed, that is, the pass2 and handle_failure steps are executed.
version: v1
type: flow
steps:
  - type: choice
    name: mychoice
    choices:
      - condition: $.status == "ready"
        # choice with steps
        steps:
          - type: pass
            name: pass1
        goto: final
      - condition: $.status == "failed"
        goto: handle_failure
    default:
      # no need to use goto
      steps:
        - type: pass
          name: pass2
  - type: fail
    name: handle_failure
    error: StatusIsNotReady
    cause: status is not ready
  - type: pass
    name: final