# 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 %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zerowork.io/using-zerowork/using-building-blocks/try-catch.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
