> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/guides-and-quickstarts/workflow-builder/error-handling-and-fallback-branches.md).

# Error handling and fallback branches

Error handling determines what a workflow does when a node fails. Use it to stop processing, retry an operation, or return an alternative response.

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSQ1Sgy933krTyK0S4JpP%2Fuploads%2FsCbfJPJ0MpjtMpuCOQqg%2FG033.mp4?alt=media&token=b6418512-a20b-4016-91a5-42efaa47c8f8>" %}

## Stop on failure

Open the node's Advanced Settings and review On Error.

![Advanced On Error settings](https://content.gitbook.com/content/SQ1Sgy933krTyK0S4JpP/blobs/RGFigcy5yOUcZUPjBXVV/assets/g033-g033-01-stop-settings.png)

Stop workflow ends the normal execution path when that node fails.

Inspect the node's error details after a failed run.

![Node error details after a failure](https://content.gitbook.com/content/SQ1Sgy933krTyK0S4JpP/blobs/2Wc1EJLrsW1grBIrg4hL/assets/g033-g033-02-failure.png)

Identify the underlying failure before deciding how the workflow should respond to it.

## Add a fallback path

Set On Error to Fallback Branch when a failure needs a separate path.

![Fallback Branch error setting](https://content.gitbook.com/content/SQ1Sgy933krTyK0S4JpP/blobs/5W42GUaz4P0R5D0d5gQI/assets/g033-g033-03-fallback-settings.png)

This exposes a failure connection but does not create the handling steps for you.

Connect the failure port to a response or recovery step and its output.

![Failure port connected to handling steps](https://content.gitbook.com/content/SQ1Sgy933krTyK0S4JpP/blobs/plgsBeD5eFTcZ5oYSSZY/assets/g033-g033-04-fallback-template.png)

Make sure the connected nodes are enabled and provide an appropriate user-facing message.

## Review the fallback result

Inspect a failed execution with the fallback connected.

![Failed execution with the fallback path](https://content.gitbook.com/content/SQ1Sgy933krTyK0S4JpP/blobs/dKRtWkEinapu3LZDzPdZ/assets/g033-g033-05-handled-error.png)

A handled failure means the alternate path ran. It does not mean the original operation succeeded.

Expand the fallback Output and review its actual response.

![Fallback Output response](https://content.gitbook.com/content/SQ1Sgy933krTyK0S4JpP/blobs/NPg66B3kNUPbvw7oTdkT/assets/g033-g033-06-fallback-result.png)

Keep internal diagnostics separate from the information the user needs to continue.

Inspect a successful execution as well.

![Successful execution using the normal path](https://content.gitbook.com/content/SQ1Sgy933krTyK0S4JpP/blobs/5cxuk4eL3DbdMn9eCPIC/assets/g033-g033-07-normal-result.png)

The normal path should provide the result while the fallback path remains unused.

## Configure retries

Review Retry on Failure, the retry count, and the interval.

![Retry count and interval settings](https://content.gitbook.com/content/SQ1Sgy933krTyK0S4JpP/blobs/vGAckLRNFN5nMb2rHDIV/assets/g033-g033-08-retry.png)

Retries can repeat an operation, so account for side effects when the node changes external data.

## Review the configuration

Review the normal and fallback connections after changing error settings.

![Normal and fallback paths after configuration](https://content.gitbook.com/content/SQ1Sgy933krTyK0S4JpP/blobs/NqRbGkUqEq3LYRCaMuQM/assets/g033-g033-09-cleanup.png)

Run the complete path to check the result users will receive.

## Important behavior

Selecting Fallback Branch exposes a connection. You still need to add and configure the nodes that handle the failure.

A fallback response does not mean the original operation succeeded. Keep retries in mind when an operation changes external data.

## Related steps

* [Workflow debugging and node results](https://docs.stackai.com/guides-and-quickstarts/workflow-builder/workflow-debugging-and-node-results.md)
* [Debug a recorded run](https://docs.stackai.com/guides-and-quickstarts/evaluations-and-observability/debug-a-recorded-run.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/guides-and-quickstarts/workflow-builder/error-handling-and-fallback-branches.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
