On this page
Sommatic Docs
Open portal

Try / Catch

Defines a scope for error handling.

View as Markdown
Open in
Flow control Available flow.try Version 1.0.0 Execution: sync

Opens an error scope: passes the payload unchanged through do, and the engine sends exceptions thrown by any node after it to the node connected to its catch edge.

This operator marks the beginning of a "Try" block. Any errors occurring in the downstream nodes connected to the 'do' port will be caught and routed to the corresponding "Catch" handler (structurally defined in the workflow graph).

Behavior:

  • Normal Flow: Passes payload to 'do'.
  • Error Scoping: The engine registers this node as the error handler for its children.
  • Catch: Errors in children trigger the configured 'Catch' operator (if any).

Use Cases:

  • Wrapping a risky API call.
  • Implementing "Compensating Transactions" for a specific step.
  • Graceful degradation (fallback logic).

How it works

  1. Returns the resolved payload through do with meta.scope try_start.
  2. The engine registers a scope whose catch node is the first node connected from this node with from.port catch (or none).
  3. When a later node throws, the engine walks the graph backwards from it; if this try node is an ancestor and has a catch node, the engine queues the catch node instead of failing the run.
  4. The catch node receives { error, source_node, source_operator }; the failing node output is stored as { error, stack }.

In a workflow

The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.

{
  "node_id": "node-try-sync",
  "label": "Try sync",
  "operator_slug": "flow.try",
  "operator_version": "1.0.0",
  "config": {}
}

Configuration

This node has no configuration fields.

Output ports

do default

Always: the start of the protected branch.

Data
{
  "order_id": "ord_123",
  "amount": 1250,
  "status": "active"
}
error

Only if resolving the config throws, which in practice does not happen.

Data
{
  "error": "<message>"
}

In expressions

What a later node can read from this node's output with $("Try / Catch").item.json.<path> (write your node's label instead of Try / Catch). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through do, from the output shown in Ports.

ExpressionEditorWorker
$("Try / Catch").item.json.payloadobjectThe worker does not return it: reads as undefined —
$("Try / Catch").item.json.order_idstringNot suggested by the editor= "ord_123"—
$("Try / Catch").item.json.amountnumberNot suggested by the editor= 1250—
$("Try / Catch").item.json.statusstringNot suggested by the editor= "active"—

— Editor: The editor suggests it, but the worker does not return it: it reads as undefined.

— Worker: The worker returns it but the editor does not suggest it: write it by hand. Keys inside objects can depend on your data or configuration (for example one key per label).

Input contract

payload object Optional

Output contract

payload object Optional

Contracts (JSON Schema)

The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.

{
  "slug": "flow.try",
  "name": "Try / Catch",
  "category": "flow",
  "version": "1.0.0",
  "description": "Defines a scope for error handling.\n\n  This operator marks the beginning of a \"Try\" block. Any errors occurring in the downstream nodes connected to the 'do' port will be caught and routed to the corresponding \"Catch\" handler (structurally defined in the workflow graph).\n\n  **Behavior:**\n  - **Normal Flow:** Passes payload to 'do'.\n  - **Error Scoping:** The engine registers this node as the error handler for its children.\n  - **Catch:** Errors in children trigger the configured 'Catch' operator (if any).\n\n  **Use Cases:**\n  - Wrapping a risky API call.\n  - Implementing \"Compensating Transactions\" for a specific step.\n  - Graceful degradation (fallback logic).",
  "capabilities": [
    "error-handling",
    "scope",
    "try-catch"
  ],
  "config_schema": {
    "type": "object",
    "properties": {}
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "payload": {
        "type": "object"
      }
    }
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "payload": {
        "type": "object"
      }
    }
  },
  "ports": [
    {
      "port_id": "do",
      "label": "Do",
      "is_default": true,
      "description": "Start of the Try block."
    }
  ],
  "execution_mode": "sync",
  "tags": [
    "error",
    "try",
    "catch",
    "scope"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_sommatic_ai",
    "profile": {
      "name": "Sommatic AI",
      "verified": true,
      "url": "https://me.veripass.com/sommatic",
      "logo_url": null
    }
  }
}

Execution

Execution
sync
Stateful
No
Capabilities
error-handlingscopetry-catch
Tags
errortrycatchscope

Notes and limits

  • Only thrown exceptions are caught. Most nodes report failures as an envelope on their own error port (for example data.transform or flow.if); those follow that port and never reach the catch node. Thrown failures include an operator that cannot be resolved, invalid credential_bindings, and workers that rethrow (such as sommatic.app.execute).
  • catch is not a declared port of this node: the engine looks for an edge with from.port catch. Without it the scope is registered but exceptions still fail the run.
  • The scope lasts until the run ends and covers every node that has the try node as an ancestor, including the catch branch: an exception inside the catch node is routed to it again until the 100-step limit fails the run.

Reviewed against the orchestrator code · 31e874b · 2026-11-26

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs