Code & Transform

Throw Error Node

Immediately stop the workflow and raise an error with a custom message and optional error code.

Overview

The Throw Error node halts workflow execution on the spot and raises an error. Use it inside a Try / Catch scope to trigger the error path, or on its own to stop the flow with a descriptive message.

This is useful for enforcing business rules, validating preconditions, or signaling failures that downstream logic should not ignore.

Configuration

Field Description Required
Error Message A descriptive message explaining what went wrong Yes
Error Code An optional code to categorize the error (e.g. ERR_VALIDATION) No

How It Works

When the Throw Error node executes:

  1. The workflow stops immediately at that point.
  2. If the node is inside a Try / Catch scope, the error is caught and the flow routes to the ERROR output of the Try / Catch node.
  3. If there is no surrounding Try / Catch, the entire workflow terminates with an error status.

The error message and error code are available as variables in the Try / Catch error path, so you can log them, return them in an API response, or use them in conditional logic.

Example: Validate Input Before Processing

Use Throw Error to reject invalid data early:

Flow Start → Condition (is input valid?)
                ├── YES → Process Data → Output
                └── NO → Throw Error ("Missing required field: email")

Example: Inside a Try / Catch

Combine with Try / Catch for controlled error handling:

Flow Start → [Try / Catch]
                 ├── Condition → Throw Error ("Unauthorized access", ERR_AUTH)
                 ├── SUCCESS → Continue
                 └── ERROR → Log Error → Send Alert

Example: Business Rule Enforcement

Stop the workflow when a business rule is violated:

HTTP Request (get account) → Condition (balance < 0?)
                                 ├── NO → Continue
                                 └── YES → Throw Error ("Insufficient balance", ERR_BALANCE)

Best Practices

  • Write clear, specific error messages that explain what went wrong and why
  • Use error codes to categorize errors programmatically (e.g. ERR_VALIDATION, ERR_AUTH, ERR_NOT_FOUND)
  • Wrap Throw Error inside a Try / Catch when you want to handle the failure gracefully instead of stopping the entire workflow
  • Use Throw Error after Condition nodes to enforce preconditions early in the flow

We update these pages often. Spotted something out of date? Tell us

AI AssistantPowered by Ubex
Beta
Ask me anything about Ubex workflows, nodes, or the API.