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

# 异常处理指令(Try、Catch、EndTry)

## 指令说明

**描述：** 异常处理模块为我们提供流程执行中处理异常情况，保证自动化流程稳定性的功能，覆盖的指令包括：Try、Catch、EndTry

## 使用示例

<img src="https://mintcdn.com/bazhuayu-rpa-docs/v_rTeoLOdoPnGE6I/helpcenter/commands/others/images/zKl2eg-04.png?fit=max&auto=format&n=v_rTeoLOdoPnGE6I&q=85&s=64bc39740d2f69de611147d6846e06bf" alt="异常处理指令(Try、Catch、EndTry)使用示例" width="660" height="270" data-path="helpcenter/commands/others/images/zKl2eg-04.png" />

<img src="https://mintcdn.com/bazhuayu-rpa-docs/v_rTeoLOdoPnGE6I/helpcenter/commands/others/images/zKl2eg-05.png?fit=max&auto=format&n=v_rTeoLOdoPnGE6I&q=85&s=c863e1f95cb5ebb87b2011ddf21e74f9" alt="异常处理指令(Try、Catch、EndTry)使用示例" width="660" height="353" data-path="helpcenter/commands/others/images/zKl2eg-05.png" />

<img src="https://mintcdn.com/bazhuayu-rpa-docs/v_rTeoLOdoPnGE6I/helpcenter/commands/others/images/zKl2eg-06.png?fit=max&auto=format&n=v_rTeoLOdoPnGE6I&q=85&s=73f9926ec98addd0bde80330b36ba950" alt="异常处理指令(Try、Catch、EndTry)使用示例" width="660" height="270" data-path="helpcenter/commands/others/images/zKl2eg-06.png" />

<img src="https://mintcdn.com/bazhuayu-rpa-docs/v_rTeoLOdoPnGE6I/helpcenter/commands/others/images/zKl2eg-01.png?fit=max&auto=format&n=v_rTeoLOdoPnGE6I&q=85&s=5ea1b6cc219ed58b1eca3d4651ab790b" alt="异常处理指令(Try、Catch、EndTry)使用示例" width="462" height="147" data-path="helpcenter/commands/others/images/zKl2eg-01.png" />

<img src="https://mintcdn.com/bazhuayu-rpa-docs/v_rTeoLOdoPnGE6I/helpcenter/commands/others/images/zKl2eg-02.png?fit=max&auto=format&n=v_rTeoLOdoPnGE6I&q=85&s=20ebd97bad3576320d1e5e5144c3b72c" alt="异常处理指令(Try、Catch、EndTry)使用示例" width="931" height="487" data-path="helpcenter/commands/others/images/zKl2eg-02.png" />

**该流程执行逻辑：**

1. 使用“按次数循环”执行 3 次，并将当前循环次数保存到变量“当前循环次数”。

2. 每次循环先进入 Try：在谷歌浏览器中新建网页并保存为“网页”，在该网页的指定元素中模拟输入 `123`，随后关闭网页。

3. 如果 Try 中的操作失败，Catch 会将错误信息保存到“错误信息”，并打印包含当前循环次数的错误日志；EndTry 结束本次异常处理，循环结束标记后进入下一次循环或结束流程。

### 效果展示

<img src="https://mintcdn.com/bazhuayu-rpa-docs/v_rTeoLOdoPnGE6I/helpcenter/commands/others/images/zKl2eg-03.png?fit=max&auto=format&n=v_rTeoLOdoPnGE6I&q=85&s=abe988606c38926ae99e70251258db80" alt="异常处理指令(Try、Catch、EndTry)效果展示" width="818" height="465" data-path="helpcenter/commands/others/images/zKl2eg-03.png" />

<Info>
  使用指令过程中遇到问题？前往 [八爪鱼RPA 开发者社区问答板块](https://rpa.bazhuayu.com/community/questions) 提问，获取官方与社区帮助。
</Info>
