
Module 5 Lesson 3: Error Handling
Prepare for the worst. Learn how to catch errors, retry failing nodes, and setup a 'Global Error Workflow' to notify you whenever something goes wrong.
Module 5 Lesson 3: Error Handling
In a perfect world, APIs never go down. In the real world, they do. A professional n8n engineer doesn't just build for "Success," they build for Failure.
1. Node Retries (The First Response)
In any node's Settings, you can enable "On Fail: Retry".
- n8n will try 3 or 5 times before giving up.
- Best for: Temporary network glitches.
2. On Error: Continue
By default, if a node fails, the whole workflow stops.
- You can change this to "Continue".
- Scenario: You are scraping 10 websites. If website #5 is down, you don't want to stop. You "Continue" and just log that #5 failed.
Visualizing the Process
graph TD
Start[Input] --> Process[Processing]
Process --> Decision{Check}
Decision -->|Success| End[Complete]
Decision -->|Retry| Process
3. The Error Workflow (The "Global Watchman")
This is the BEST way to handle errors.
- Create a separate workflow with an "Error Trigger" node.
- In your Main Workflow settings, set "Error Workflow" to point to it.
- Now: Whenever the Main Workflow fails, the Error Workflow starts Instantly.
- It can send you a Slack message: "Hey! Workflow 'Payrolls' just crashed on Node 'Stripe-Charge'. Error: 'Card Expired'."
4. Why Use an Error Workflow?
- DRY: You don't have to add an "Email me on failure" node to every single workflow.
- Logging: You can save all errors to a Google Sheet to see which APIs are the most "Flaky" this month.
Exercise: The Failure Lab
- Create a "Global Error Handler" workflow that sends a message (or just logs to console).
- Create a "Test" workflow with an HTTP Request to a fake URL (Review Module 3, Lesson 5).
- Connect the Test workflow to the Error Handler in the Workflow Settings.
- Run the test. Did the Error Handler start?
- Look at the data in the Error Handler. Does it tell you WHICH node failed?
- Research: What is "On Error -> Switch to different branch"?
Summary
Error handling is the difference between an "Amateur script" and a "Business-critical system." By using retries and Global Error Workflows, you ensure that even when things break, you are the first to know and have the data to fix it.
Next Lesson: Continuous cycles: Loop mechanisms in n8n.