Catch Block — Examples
Catch Block patterns: error logging, alerting, type-based branching, Jira ticketing, and user-friendly responses.
01 Slack Alert with Exception Details
The simplest and most common catch pattern — send an immediate Slack alert to the engineering channel with the full exception context, plus the workflow variable data that was being processed when the failure occurred.
// Catch Block node (default config)
{
"nodeType": "CatchBlock",
"id": "catch_erp_call",
"label": "Catch — ERP API Errors"
}
// Slack node connected to catch_erp_call's success port:
{
"channel": "#workflow-errors",
"message": ":red_circle: *Workflow Error — ERP Sync*\n\n*Type:* {{ $mem.__exception_type__ }}\n*Message:* {{ $mem.__exception_message__ }}\n*Order ID:* {{ $var.order_id }}\n*Workflow Run:* {{ $ctx.workflow_instance_id }}\n\nInvestigate: https://app.bizfirstai.com/runs/{{ $ctx.workflow_instance_id }}"
}
02 Log Error to Database
Persist full error details to a workflow_errors table for historical analysis, SLA reporting, and support ticket correlation. The stack trace is stored for post-incident debugging.
// Catch Block node
{
"nodeType": "CatchBlock",
"id": "catch_payment",
"label": "Catch — Payment Errors"
}
// Database Insert node in catch scope:
{
"table": "workflow_errors",
"data": {
"workflow_id": "{{ $ctx.workflow_definition_id }}",
"run_id": "{{ $ctx.workflow_instance_id }}",
"node_id": "http_payment_gateway",
"error_type": "{{ $mem.__exception_type__ }}",
"error_message": "{{ $mem.__exception_message__ }}",
"stack_trace": "{{ $mem.__exception_stacktrace__ }}",
"context_json": "{ \"order_id\": \"{{ $var.order_id }}\", \"amount\": {{ $var.amount }} }",
"occurred_at": "{{ $now }}"
}
}
03 Exception-Type Branching with Switch Node
Different exception types require different handling. A Switch node on $mem.__exception_type__ routes to the appropriate recovery action — retry for timeouts, credential refresh for auth errors, and a generic alert for all others.
// Catch Block
{
"nodeType": "CatchBlock",
"id": "catch_api",
"label": "Catch — API Errors"
}
// Switch node on $mem.__exception_type__:
// Case "TimeoutException"
// → Set Var: retry_needed = true
// → Delay: 30 seconds
// → Retry HTTP Request (loop back)
//
// Case "UnauthorizedException"
// → HTTP Request: Refresh OAuth Token
// → Slack: "API credentials refreshed — retrying workflow"
// → Restart workflow from auth step
//
// Default case
// → Slack Alert: generic error notification
// → Set Order Status: processing_failed
04 Create Jira Ticket on Critical Failure
For high-priority workflows, automatically create a Jira bug ticket when an error occurs. The ticket is pre-populated with exception details, making it immediately actionable for the engineering team.
// Catch Block
{
"nodeType": "CatchBlock",
"id": "catch_critical",
"label": "Catch — Critical Workflow Error"
}
// HTTP Request to Jira REST API in catch scope:
{
"url": "https://yourcompany.atlassian.net/rest/api/3/issue",
"method": "POST",
"headers": { "Authorization": "Basic {{ $env.JIRA_TOKEN }}" },
"body": {
"fields": {
"project": { "key": "OPS" },
"issuetype": { "name": "Bug" },
"priority": { "name": "High" },
"summary": "Workflow Error: {{ $mem.__exception_type__ }} in {{ $ctx.workflow_definition_id }}",
"description": {
"type": "doc",
"version": 1,
"content": [{
"type": "paragraph",
"content": [{
"type": "text",
"text": "Error: {{ $mem.__exception_message__ }}\n\nWorkflow Run: {{ $ctx.workflow_instance_id }}\nContext: Order {{ $var.order_id }}\n\nStack Trace:\n{{ $mem.__exception_stacktrace__ }}"
}]
}]
}
}
}
}
$var.jira_ticket_id and included in the Slack alert for cross-reference.
05 Return User-Friendly Error Response
In a customer-facing API workflow triggered by an external webhook, the catch block constructs a clean error response and returns it via the HTTP Response node — hiding internal exception details from the client.
// Catch Block
{
"nodeType": "CatchBlock",
"id": "catch_api_response",
"label": "Catch — API Response Errors"
}
// Set Variable node in catch scope:
{
"error_code": "PROCESSING_ERROR",
"error_user_message": "We were unable to process your request at this time. Please try again in a few minutes.",
"error_reference": "{{ $ctx.workflow_instance_id }}"
}
// HTTP Response node (returns error to caller):
{
"status_code": 500,
"body": {
"success": false,
"error": {
"code": "{{ $var.error_code }}",
"message": "{{ $var.error_user_message }}",
"reference": "{{ $var.error_reference }}"
}
}
}