> For the complete documentation index, see [llms.txt](https://docs.zerowork.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zerowork.io/using-zerowork/using-building-blocks/try-catch.md).

# Try-Catch

You can add any building block — or a sequence of multiple building blocks — after the **Start Try-Catch** block. All of these blocks will be part of the Try-Catch scope.

If an error happens inside this scope, the TaskBot will immediately continue along the **On Catch Error** path, where you can define how to handle the error.

After either the success path or the error path is completed, the TaskBot will continue along the **After Try-Catch** path.

<figure><img src="/files/TuIOcNQ3UzV01pXjxMX4" alt=""><figcaption></figcaption></figure>

### Examples

1. If any error (no differentiation) occurs inside a loop, break the loop and continue after the loop.

<figure><img src="/files/Wmw2JuvXCuZi70vvPSOH" alt=""><figcaption></figcaption></figure>

2. Different try-catch scopes with different error handling strategies for different building blocks.

<figure><img src="/files/M8eyjqQNRrP0YbWjVzOp" alt=""><figcaption></figcaption></figure>

3. Record the error message and handle the error differently depending on the error.

<figure><img src="/files/ZL6h0Zogbluc8UhdEufl" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
If the TaskBot can’t start its run at all, the error won’t be caught — even if you wrap the entire workflow in a try-catch block. This usually happens for one of two reasons:

* Outdated agent version
* Invalid TaskBot set-up&#x20;
  {% endhint %}
