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

# arc:try

> 将 arc:try 与 arc:catch 结合使用，在脚本中创建异常处理块，以捕获 try 主体中抛出的 RSBException。

export const siteNameShort = "知行之桥";

使用 `arc:try` 和 [arc:catch](./op-arc-catch) 关键字可以在脚本中创建异常处理块。如果 `arc:try` 主体内的任何关键字抛出 RSBException，应用程序会在相同作用域中查找匹配的 `arc:catch` 关键字并执行 catch 主体。

## 参数

无

## 控制属性

无

## 示例

抛出并捕获异常。在关键字的作用域内，`arc:ecode` 和 `arc:emessage` 属性会添加到当前对象中并推出。

```xml theme={null}
<arc:call op="...">
  <arc:try>
    <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:try>
</arc:call>
```

## 另请参阅

* [arc:catch](./op-arc-catch)：处理抛出的异常。
* [arc:throw](./op-arc-throw)：强制抛出异常。
