Flows
Node Types
Error Handling

Error Handling Nodes

Nodes for catching, handling, and throwing errors in flows.

Available Nodes

Error Trigger

Special trigger that activates when an error occurs in the flow.

Configuration:

  • catchAll - Catch all errors in the flow
  • nodeIds - Specific nodes to catch errors from

Variables Provided:

  • error.message - Error message
  • error.code - Error code (if available)
  • error.nodeId - Which node threw the error
  • error.stack - Stack trace (for debugging)

Example:

Main Flow:
  Webhook → Fetch Data → Process → Respond

Error Handler (connected to Error Trigger):
  Log Error → Send Alert → Respond with Error

Use Case: Global error handling, alerting, cleanup.


Throw Error

Explicitly throw an error to stop execution or trigger error handling.

Configuration:

  • message - Error message
  • code - Error code (optional)
  • data - Additional error data (optional)

Example:

{
  "message": "Invalid order: missing required fields",
  "code": "VALIDATION_ERROR",
  "data": {
    "missingFields": ["email", "address"]
  }
}

Use Case: Validation failures, business logic errors, early exit.


Error Handling Patterns

Try-Catch Pattern

┌─────────────────────────────────────┐
│ Main Flow                           │
│ ┌─────────────────────────────────┐ │
│ │ Risky Operation (API Call)      │ │
│ └───────────────┬─────────────────┘ │
│                 │                   │
│         Success │ Error             │
│                 ↓                   │
│ ┌─────────────────────────────────┐ │
│ │ Continue with result            │ │
│ └─────────────────────────────────┘ │
└─────────────────────────────────────┘

         │ Error propagates

┌─────────────────────────────────────┐
│ Error Handler                       │
│ ┌─────────────────────────────────┐ │
│ │ Log error, send alert, respond  │ │
│ └─────────────────────────────────┘ │
└─────────────────────────────────────┘

Validation with Throw

// In a Code node
if (!inputs.email || !inputs.email.includes('@')) {
  throw new Error('Invalid email address');
}
 
if (inputs.amount < 0) {
  throw new Error('Amount cannot be negative');
}
 
// Continue with valid data
return { validated: true };

Retry with Backoff

┌──→ API Call ──→ If Error ──→ Increment Retry ──→ If Retries < 3 ──┐
│                                                                    │
│                                                      Yes           │
└────────────────────────── Wait (exponential) ←─────────────────────┘

                                   │ No (max retries)

                            Throw Final Error

Best Practices

Always Handle Errors

Don't let flows fail silently. Add error handling to:

  • Log errors for debugging
  • Alert your team
  • Return meaningful error responses

Graceful Degradation

When possible, continue with partial success:

Send to 100 users → 3 fail → Log failures → Continue with 97 successes

Error Response Format

Standardize error responses:

{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid input provided",
    "details": { ... }
  }
}

Cleanup on Error

Use error handlers to clean up resources:

  • Rollback database changes
  • Release locks
  • Cancel pending operations

See Also: