> ## Documentation Index
> Fetch the complete documentation index at: https://docs.arc.cdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# arc:catch

> Creates an exception-handling block in a script, allowing you to selectively or broadly catch exceptions thrown within arc:try or other implicit try scopes.

export const siteNameShort = "Arc";

Use the `arc:catch` keyword to create an exception-handling block in a script. In addition to [arc:try](./op-arc-try), you can contain an `arc:catch` block in any of the following keywords, the scope of which serves as an implicit `arc:try` section:

* [arc:call](./op-arc-call)
* [arc:render](./op-arc-render)
* [arc:script](./op-arc-script)

## Parameters

* **code**: Allows you to selectively catch exceptions. To catch all exceptions, use an asterisk (`*`).

## Control Attributes

* **\_code**: The code of the caught exception.
* **\_description**: A short description of the caught exception.
* **\_details**: More information about the exception, if available.

## Examples

Wrap a more user-friendly message around the error output from a batch file or shell command:

```xml theme={null}
<arc:try>
<arc:call op="sysExecute">
  <arc:check attr="sys:error">
    <arc:throw code="myerror" description="Batch file could not be executed" details="[sys:error]"/>
  </arc:check>
</arc:call>
<arc:catch code="*">
  <arc:call op="appSendEmail"/>
</arc:catch>
</arc:try>
```

Throw and catch an exception. Inside an [arc:call](./op-arc-call), an RSBException is thrown and caught. Inside the scope of the keyword, the `arc:ecode` and `arc:emessage` attributes are added to the current item and pushed out.

```xml theme={null}
<arc:call op="...">
  <arc:throw code="myerror" description="thedescription" details="Other Details."/>
  <arc:catch code="myerror">
    <arc:set attr="arc:ecode" value="[_code]"/>
    <arc:set attr="arc:emessage" value="[_description]: [_details]"/>
    <arc:push/>
  </arc:catch>
</arc:call>
```

Catch all exceptions:

```xml theme={null}
<arc:catch code="*">
  An exception occurred. Code: [_code], Message: [_description]
</arc:catch>
```

## See Also

* [arc:try](./op-arc-try): Define a scope to catch exceptions.
* [arc:throw](./op-arc-throw): Force an exception.
