mirror of
https://github.com/n8n-io/n8n-docs.git
synced 2025-11-20 17:48:34 +00:00
Update Ch 4 wording and styles
This commit is contained in:
parent
402f9eae0e
commit
ff928470ed
@ -4,44 +4,55 @@ contentType: tutorial
|
||||
|
||||
# Dealing with errors in workflows
|
||||
|
||||
Sometimes it can happen that you're building a nice workflow, but when you try to execute it, it fails. There are many reasons why workflows executions may fail (some more or less mysterious), for example when a node isn't configured correctly or a third-party service that you're trying to connect to isn't working properly.
|
||||
Sometimes you build a nice workflow, but it fails when you try to execute it. Workflow executions may fail for a variety of reasons, ranging from straightforward problems with incorrectly configuring a node or a failure in a third-party service to more mysterious errors.
|
||||
|
||||
But don't panic. We will show you some ways in which you can troubleshoot the issue, so you can get your workflow up and running as soon as possible.
|
||||
But don't panic. In this lesson, you'll learn how you can troubleshoot errors so you can get your workflow up and running as soon as possible.
|
||||
|
||||
|
||||
## Checking failed workflows
|
||||
|
||||
When one of your workflows fails, it's helpful to check the execution log by clicking on [**Executions**](/editor-ui/#executions){:target="_blank" .external} in the left-side panel. The executions log shows you a list of the latest execution time, status, mode, and running time of your saved workflows.
|
||||
n8n tracks executions of your workflows.
|
||||
|
||||
To investigate a specific failed execution from the list, click on the name or 'view' button on the row of the respective execution.
|
||||
When one of your workflows fails, you can check the Executions log to see what went wrong. The Executions log shows you a list of the latest execution time, status, mode, and running time of your saved workflows.
|
||||
|
||||
<figure><img src="/_images/courses/level-two/chapter-four/explanation_workflowexecutions.png" alt="" style="width:100%"><figcaption align = "center"><i>Workflow Executions window</i></figcaption></figure>
|
||||
Open the Executions log by selecting [**Executions**](/editor-ui/#executions) in the left-side panel.
|
||||
|
||||
To investigate a specific failed execution from the list, select the name or the **View** button that appears when you hover over the row of the respective execution.
|
||||
|
||||
<figure><img src="/_images/courses/level-two/chapter-four/explanation_workflowexecutions.png" alt="Executions log" style="width:100%"><figcaption align = "center"><i>Executions log</i></figcaption></figure>
|
||||
|
||||
|
||||
This will open the workflow in read-only mode, where you can see the execution of each node. This representation can help you identify at what point the workflow ran into issues.
|
||||
|
||||
To toggle between viewing the execution and the editor, click the **Editor | Executions** button at the top of the page.
|
||||
To toggle between viewing the execution and the editor, select the **Editor | Executions** button at the top of the page.
|
||||
|
||||
<figure><img src="/_images/courses/level-two/chapter-four/explanation_workflowexecutions_readonly.png" alt="" style="width:100%"><figcaption align = "center"><i>Workflow execution view</i></figcaption></figure>
|
||||
<figure><img src="/_images/courses/level-two/chapter-four/explanation_workflowexecutions_readonly.png" alt="Workflow execution view" style="width:100%"><figcaption align = "center"><i>Workflow execution view</i></figcaption></figure>
|
||||
|
||||
## Catching erroring workflows
|
||||
|
||||
To catch failed workflows, create a separate [Error Workflow](/flow-logic/error-handling/error-workflows/) with the [Error Trigger node](/integrations/builtin/core-nodes/n8n-nodes-base.errortrigger/), which gets executed if the main execution fails.
|
||||
To catch failed workflows, create a separate [**Error Workflow**](/flow-logic/error-handling/error-workflows/) with the [**Error Trigger node**](/integrations/builtin/core-nodes/n8n-nodes-base.errortrigger/). This workflow will only execute if the main workflow execution fails.
|
||||
|
||||
Then, you can take further actions by connecting other nodes, for example sending notifications using email or Slack about the failed workflow and its errors. To receive error messages for a failed workflow, you need to select the option `Error Workflow` in the [Workflow Settings](/courses/level-one/chapter-5/chapter-5.8/) of the respective workflow.
|
||||
Use additional nodes in your **Error Workflow** that make sense, like sending notifications about the failed workflow and its errors using email or Slack.
|
||||
|
||||
The only difference between a regular workflow and an Error Workflow is that the latter contains an Error Trigger node. Make sure to create this node before you set a workflow as Error Workflow.
|
||||
To receive error messages for a failed workflow, set the **Error Workflow** in the [Workflow Settings](/workflows/settings/) to an Error Workflow that uses an **Error Trigger node**.
|
||||
|
||||
The only difference between a regular workflow and an Error Workflow is that the latter contains an **Error Trigger node**. Make sure to create this node before you set this as another workflow's designated Error Workflow.
|
||||
|
||||
/// note | Error workflows
|
||||
- You don't need to activate workflows that use the Error Workflow node.
|
||||
- A workflow that uses the *Error Trigger node* uses itself as the error workflow.
|
||||
- The Error Trigger node is designed to get triggered only when the monitored workflow gets executed automatically. This means you can't test this (to see the result of) an error workflow while executing the monitored workflow manually.
|
||||
- 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.
|
||||
- You can set the same Error Workflow for multiple workflows.
|
||||
///
|
||||
|
||||
### Exercise
|
||||
|
||||
In the previous chapters, you've built several small workflows. Now, pick one of them that you want to monitor. Create an Error Workflow that sends a message to a communication platform (for example, Slack, Discord, Telegram, or even email) if that workflow fails. Don't forget to set this Error Workflow in the settings of the monitored workflow.
|
||||
In the previous chapters, you've built several small workflows. Now, pick one of them that you want to monitor and create an Error Workflow for it:
|
||||
|
||||
1. Create a new Error Workflow.
|
||||
2. Add the **Error trigger node**.
|
||||
3. Connect a node for the communication platform of your choice to the Error trigger node, like [Slack](/integrations/builtin/app-nodes/n8n-nodes-base.slack/), [Discord](/integrations/builtin/app-nodes/n8n-nodes-base.discord/), [Telegram](/integrations/builtin/app-nodes/n8n-nodes-base.telegram/), or even [Gmail](/integrations/builtin/app-nodes/n8n-nodes-base.gmail/) or a more generic [Send Email](/integrations/builtin/core-nodes/n8n-nodes-base.sendemail/).
|
||||
4. In the workflow you want to monitor, open the [Workflow Settings](/workflows/settings/) and select the new Error Workflow you just created. Note that this workflow needs to run automatically to trigger the error workflow.
|
||||
|
||||
??? note "Show me the solution"
|
||||
|
||||
@ -49,7 +60,7 @@ In the previous chapters, you've built several small workflows. Now, pick one of
|
||||
|
||||
<figure><img src="/_images/courses/level-two/chapter-four/exercise_errors_errortriggernode_workflow.png" alt="" style="width:100%"><figcaption align = "center"><i>Error workflow</i></figcaption></figure>
|
||||
|
||||
To check the configuration of the nodes, you can copy-paste the JSON code of the workflow:
|
||||
To check the configuration of the nodes, you can copy the JSON workflow code below and paste it into your Editor UI:
|
||||
|
||||
```json
|
||||
{
|
||||
@ -106,17 +117,25 @@ In the previous chapters, you've built several small workflows. Now, pick one of
|
||||
|
||||
## Throwing exceptions in workflows
|
||||
|
||||
Another way of troubleshooting workflows is to include a [Stop and Error node](/integrations/builtin/core-nodes/n8n-nodes-base.stopanderror/){:target="_blank" .external} in your workflow. This node throws an error, which can be set to one of two error types: an error message or an error object. The error message returns a custom message about the error, while the error object returns the type of error.
|
||||
Another way of troubleshooting workflows is to include a [**Stop and Error node**](/integrations/builtin/core-nodes/n8n-nodes-base.stopanderror/) in your workflow. This node throws an error. You can specify the error type:
|
||||
|
||||
The Stop and Error node can only be added as the last node in a workflow.
|
||||
- **Error Message**: returns a custom message about the error
|
||||
- **Error Object**: returns the type of error
|
||||
|
||||
You can only use the **Stop and Error node** as the last node in a workflow.
|
||||
|
||||
/// note | When to throw errors
|
||||
Throwing exceptions with the Stop and Error node is useful for verifying the data (or assumptions about the data) from a node and returning custom error messages.
|
||||
Throwing exceptions with the **Stop and Error node** is useful for verifying the data (or assumptions about the data) from a node and returning custom error messages.
|
||||
|
||||
If you are working with data from a third-party service, you may come across problems such as: wrongly formatted JSON output, data with the wrong type (for example, numeric data that has a non-numeric value), missing values, or errors from remote servers.
|
||||
If you are working with data from a third-party service, you may come across problems such as:
|
||||
|
||||
- Wrongly formatted JSON output
|
||||
- Data with the wrong type (for example, numeric data that has a non-numeric value)
|
||||
- Missing values
|
||||
- Errors from remote servers
|
||||
|
||||
Though this kind of invalid data might not cause the workflow to fail right away, it could cause problems later on, and then it can become difficult to track the source error. This is why it's better to throw an error at the time you know there might be a problem.
|
||||
|
||||
<figure><img src="/_images/courses/level-two/chapter-four/exercise_errors_stopanderror.png" alt="" style="width:100%"><figcaption align = "center"><i>Stop and Error node with error message</i></figcaption></figure>
|
||||
<figure><img src="/_images/courses/level-two/chapter-four/exercise_errors_stopanderror.png" alt="Stop and Error node with error message" style="width:100%"><figcaption align = "center"><i>Stop and Error node with error message</i></figcaption></figure>
|
||||
///
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user