This topic describes the overview and examples of error handling during workflow integration.
Overview
Expected or unexpected errors may occur in the workflow integration of CloudFlow. You can retry the current state or move to the next state based on the scenario. The FnF.ALL
keyword is a special option that hits all errors.
The following table describes the attributes of the error handling logic.
Attribute | Type | Required | Description | Example |
Errors | String | Yes | The errors that can be hit. | string{"err1","err2"} |
Description | String | No | The description of the error. | describe it here |
Retry | String | No | The retry policy. This attribute and the Next attribute are mutually exclusive. This attribute has a lower priority than the Next attribute. | See Retry. |
Next | String | No | The next state that is executed after the current state is complete. This attribute and the Retry attribute are mutually exclusive. This attribute has a higher priority than the Retry attribute. | Pass1 |
OutputConstructor | Map[String]Any | No | The output constructor. This attribute is used together with the Next attribute. | See OutputConstructor. |
Retry
Attribute | Type | Required | Description | Example |
MaxAttempts | Int | Yes | The maximum number of retries. | 5 |
FixedBackoff | Int | No | The first backoff delay. | 2 |
Multiplier | Float | No | The backoff exponent. | 1.5 |
Next
The OutputConstructor attribute is used together with the Next attribute. If an error occurs in a state, no expected outputs are generated in the state. The flow cannot proceed even if the flow transits to the next state. In this case, you can use the OutputConstructor attribute to construct an output and use the output as the input of the next state.
Example
Type: StateMachine
Name: my-wkfl
SpecVersion: v1
StartAt: Pass1
States:
- Type: Task
Name: Mytestfc
Action: FC:InvokeFunction
TaskMode: RequestComplete
OnErrors:
- Errors:
- MyCustomException
Description: my retry policy
Retry:
MaxAttempts: 5
FixedBackoff: 2
Multiplier: 2.5
- Errors:
- FnF.ALL
Description: my catch policy
OutputConstructor:
FieldQ: 123
Next: Pass1
- Type: Pass
Name: Pass1
End: true
In the preceding example, if an error occur in the Mytestfc integration and the error hits MyCustomException, the system retries the state up to five times based on the retry policy. After the maximum number of retries is exhausted, the flow ends.
If other errors occur, the errors hit FnF.ALL
. The system uses the OutputConstructor attribute to construct an output and uses the output as the input of the Pass1 state. Then, the flow transits to the Pass1 state.