Skip to content

错误触发节点#

¥Error Trigger node

你可以使用“错误触发器”节点创建错误工作流。当另一个链接的工作流失败时,此节点会获取失败工作流及其错误的详细信息,并运行该错误工作流。

¥You can use the Error Trigger node to create error workflows. When another linked workflow fails, this node gets details about the failed workflow and the errors, and runs the error workflow.

用法#

¥Usage

  1. Create a new workflow, with the Error Trigger as the first node.
  2. Give the workflow a name, for example Error Handler.
  3. Select Save.
  4. In the workflow where you want to use this error workflow:
    1. Select Options Options menu icon > Settings.
    2. In Error workflow, select the workflow you just created. For example, if you used the name Error Handler, select Error handler.
    3. Select Save. Now, when this workflow errors, the related error workflow runs.

请注意以下内容:

¥Note the following:

  • 如果工作流使用“错误触发”节点,则无需激活该工作流。

¥If a workflow uses the Error Trigger node, you don't have to activate the workflow.

  • 如果工作流包含错误触发节点,默认情况下,工作流会使用自身作为错误工作流。

¥If a workflow contains the Error Trigger node, by default, the workflow uses itself as the error workflow.

  • 手动运行工作流时,无法测试错误工作流。“错误触发器”仅在自动工作流出错时运行。

¥You can't test error workflows when running workflows manually. The Error Trigger only runs when an automatic workflow errors.

模板和示例#

¥Templates and examples

Template widget placeholder.

相关资源#

¥Related resources

你可以使用 停止和错误 节点向错误触发器发送自定义消息。

¥You can use the Stop And Error node to send custom messages to the Error Trigger.

在 n8n 工作流中了解更多关于 错误工作流 的信息。

¥Read more about Error workflows in n8n workflows.

错误数据#

¥Error data

The default error data received by the Error Trigger is:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
[
	{
		"execution": {
			"id": "231",
			"url": "https://n8n.example.com/execution/231",
			"retryOf": "34",
			"error": {
				"message": "Example Error Message",
				"stack": "Stacktrace"
			},
			"lastNodeExecuted": "Node With Error",
			"mode": "manual"
		},
		"workflow": {
			"id": "1",
			"name": "Example Workflow"
		}
	}
]

All information is always present, except:

  • execution.id: requires the execution to be saved in the database. Not present if the error is in the trigger node of the main workflow, as the workflow doesn't execute.
  • execution.url: requires the execution to be saved in the database. Not present if the error is in the trigger node of the main workflow, as the workflow doesn't execute.
  • execution.retryOf: only present when the execution is a retry of a failed execution.

If the error is caused by the trigger node of the main workflow, rather than a later stage, the data sent to the error workflow is different. There's less information in execution{} and more in trigger{}:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
  "trigger": {
    "error": {
      "context": {},
      "name": "WorkflowActivationError",
      "cause": {
        "message": "",
        "stack": ""
      },
      "timestamp": 1654609328787,
      "message": "",
      "node": {
        . . . 
      }
    },
    "mode": "trigger"
  },
  "workflow": {
    "id": "",
    "name": ""
  }
}