百度智能云函数计算 CFC 工作流失败(fail)节点
文档简介:
fail 节点用于标记工作流已执行失败,并结束整个工作流的执行。它通常会跟 switch 节点结合使用,在 switch 节点判断某个条件已满足的情况下跳转到 fail 节点,结束执行。fail 节点内可以自定义错误码和错误信息。
概述
fail 节点用于标记工作流已执行失败,并结束整个工作流的执行。它通常会跟 switch 节点结合使用,在 switch 节点判断某个条件已满足的情况下跳转到 fail 节点,结束执行。fail 节点内可以自定义错误码和错误信息。
参数
以下为 fail 节点所包含的参数字段:
字段 | 类型 | 描述 |
---|---|---|
type(必需) | string | 节点类型,值为 "fail" |
name(必需) | string | 节点名称 |
error(可选) | string | 错误状态码 |
cause(可选) | string | 错误信息 |
description(可选) | string | 节点描述信息 |
fail 节点已内含了结束执行,因此不允许再指定 next 或 end 参数。
示例
示例工作流定义如下,读取节点输入数据中的 .ready 字段值,读取 ".ready" 的值,若为 "no" 则跳转到失败节点、结束执行。
name: demo start: checkReady states: - type: switch name: checkReady conditions: -
condition: .ready == "yes" next: handleReady - condition: .ready == "no" next:
handleNotReady default: next: handleReady - type: fail name: handleNotReady error: Custom.
NotReady cause: "it's not ready yet" - type: succeed name: handleReady