The Failure state is also an end state that signifies the failure of the previous task executed in the Circuit and stops its execution, marking it as a failure. It is used to represent a failed execution for the user's reference.
Example Use Case: In the employee onboarding case, specifically during the employee document verification stage, when the verification status indicates a failure, we can employ a Failure state to terminate execution along with an error message and reason for failure.
Builder View
To configure a Failure state to your circuit:
-
In Builder View, drag and drop the Failure state from the left pane into your circuit or click the required Failure state in your circuit.
-
Under Configuration, you can add a specific Error Message and an optional Reason in the state for your reference that will be displayed in the execution response to help in debugging.
- There is no next state for a Failure state since it is the last state for that path.
- You will also not be able to configure an input path or output path for a Failure state.
Code View
The below JSON is used in Code View and the equivalent fields for adding failure details are errorMessage and reason.
Failure state example:
"Offer Cancelled": {
"type": "failure",
"error_message": "Document verification unsuccessful",
"reason": "Documents submitted are invalid"
}