catch

使用 catch 扩展以捕获在 API 调用期间发生的错误。

catch 扩展采用以下格式:
catch:
   - errors:
      - Error_1
      - Error_2
   - execute:
      assembly_1
   - errors:
      - Error_3
   - execute:
      assembly_2
   - default:
      assembly_3

下表显示 catch 扩展的属性:

表 1. catch 扩展的属性
属性 必需 描述 Type
errors 将针对其激活 catch 的错误。 有关错误列表,请参阅 组合件捕获支持的错误案例 数组(字符串)
execute 在激活 catch 时将执行的组合件的部分。 数组(对象)
default False 在错误未触发其他 catch 时将执行的组合件的部分。 它的行为方式相同,结构与 execute 相同 数组(对象)
以下是 catch 扩展的示例:
    catch:
      - errors:
          - ConnectionError
          - JavaScriptError
        execute:
          - activity-log:
              title: activity-log
              content: activity
              error-content: payload
      - default:
          - activity-log:
              title: activity-log
              content: activity
              error-content: payload