跳到主要内容

错误处理-节点抛出错误时触发

当节点抛出错误时触发流程

问题背景

在节点抛出错误时,触发流程

解决方案

使用 捕获错误 节点 接收错误并触发流程

示例

error-trigger

示例JSON

[{"id":"2bd6810d.e22ece","type":"catch","z":"e028a121bc4ae061","name":"","scope":["3d9e94fa01261a13"],"uncaught":false,"x":360,"y":2580,"wires":[["d16b9fac.8212a"]]},{"id":"d16b9fac.8212a","type":"debug","z":"e028a121bc4ae061","logName":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","logLevel":"info","dataType":"field","syntax":"mustache","template":"","x":540,"y":2580,"wires":[]},{"id":"c5ee9670.5dbbd8","type":"inject","z":"e028a121bc4ae061","name":"Trigger error","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":360,"y":2520,"wires":[["3d9e94fa01261a13"]]},{"id":"3d9e94fa01261a13","type":"MySQL","z":"e028a121bc4ae061","name":"","queryOptType":"editor","queryOpt":"sqlStr","paramsOptType":"none","paramsOpt":"queryParams","parseMustache":true,"outField":"payload","query":"","x":620,"y":2520,"wires":[[]]}]

运行结果

点击注入节点 Trigger error,触发 MySQL 节点抛出错误,因为 MySQL 的查询语句是空的,所以会抛出一个:Query was Empty 的错误提示

error-trigger-result