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
statusin the input isready, thepass1andfinalsteps of the first choice are executed in sequence. - If the value of
statusin the input isfailed, the goto instructions of the second choice are executed, the choice step ends, and thehandle_failurestep is executed. Thehandle_failurestep is a fail step. Therefore, after it is executed, thefinalstep will not be executed. - If the input does not contain
statusor the value ofstatusis neitherreadynorfailed, the default choice is executed, that is, thepass2andhandle_failuresteps 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