# TryCatch

The TryCatch function allows Functions to handle errors. Use this function when you expect errors and want to handle them.

***

## Properties

### Options

You must define a 'Try' and you can opt to have a 'Catch', or 'Finally' or both when using this function.

*'Try'* is a required path for the TryCatch function. The Function will always *try* and execute some logic.

*'Catch'* is optional and does not have to be used. If no *catch* is configured, the logic will be tried, but any error generated in the 'Try' will be ignored. The 'Catch' logic needs to handle the error. You may want to log this to a database or file.

*'Finally'* is optional and does not have to be used. *'Finally'* contains logic that will always execute, regardless of whether the 'Try' or the 'Catch' executed. If you are, for example, creating some files and are trying to read these, you may want to clear the folder of the files again when you are done with them, regardless of whether you could read them or not. The logic to remove these files or back them up to another folder would fit well into 'Finally'.

## Tutorial video

{% embed url="<https://youtu.be/DAAaDlQOoYk>" %}

\
\\


---

# 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.linx.software/reference/plugins/linx/content/trycatch.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.
