> 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="https://3220183989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fg9LcR8XM7TGOzOCDGsCS%2Fuploads%2FZR7AHdkgISuhCDFlYun7%2FCleanShot%202025-04-27%20at%2008.54.16.png?alt=media&amp;token=e6d9aec4-c7bc-4b48-9ea8-ffbe56464de0" 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="https://3220183989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fg9LcR8XM7TGOzOCDGsCS%2Fuploads%2FiXJQoLiT4UQBQQzYzO8s%2FCleanShot_2025-04-29_at_07.13.25.png?alt=media&amp;token=6da87a39-6204-4c2c-ba55-b4be6433de73" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://3220183989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fg9LcR8XM7TGOzOCDGsCS%2Fuploads%2FQIsLunUOiXQaBFyJiQWw%2FCleanShot_2025-04-29_at_07.14.35.png?alt=media&amp;token=c6cbc631-8eba-4b61-a9ef-31731129be23" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://3220183989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fg9LcR8XM7TGOzOCDGsCS%2Fuploads%2FAlnWuqoNPBS4PdWopVmA%2FCleanShot_2025-04-29_at_07.28.30.png?alt=media&amp;token=698b2c08-5bbc-45f0-8fbf-88412459ddda" 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 %}
