Skip to content
Development
Skill

/output-error-try-catch

Handle errors caught in Output workflows without losing failure context. Use when adding workflow try/catch logic, fallbacks, partial-failure handling, custom Error classes, or typed checks for errors thrown by steps and evaluators.

From plugin
output
44451 skills5 agents

Claude Code

$ npx -y skills add growthxai/output --skill output-error-try-catch --agent claude-code

SKILL.md

output-error-try-catch.SKILL.md
name: output-error-try-catch
description: Handle errors caught in Output workflows without losing failure context. Use when adding workflow try/catch logic, fallbacks, partial-failure handling, custom Error classes, or typed checks for errors thrown by steps and evaluators.
allowed-tools: [Bash, Read, Write, Edit]

Handle Errors in Workflows

Understand when workflow catch blocks run

Steps and evaluators run as Temporal Activities. Temporal applies their configured retry policy before returning a successful result or throwing a final failure to workflow code.

A workflow `catch` around a step therefore runs only after the step has exhausted its Activity retries. Catching that failure does not disable or bypass the Activity retry policy.

The catch block decides what the workflow does with the final failure:

  • Return a fallback value.
  • Run an alternative step.
  • Record a partial failure and continue.
  • Handle an expected error type.
  • Rethrow the error and fail the workflow.

Let unexpected failures propagate

Do not add a catch block that only wraps or logs an error. It can discard Temporal's failure type, cause chain, and retry metadata.

// Avoid: replaces the original Temporal failure chain.
try {
  return await fetchData( input );
} catch ( error ) {
  throw new Error( `Fetch failed: ${error.message}` );
}

When the workflow cannot recover, let the step failure propagate:

export default workflow( {
  name: 'fetch_workflow',
  fn: async input => fetchData( input )
} );

If a catch block handles only known failures, always rethrow everything else.

Check specific error types with hasErrorType

Errors crossing from a step or evaluator into workflow code are serialized into a Temporal failure cause chain. The original JavaScript object identity is not preserved, so `error instanceof CustomError` is unreliable.

Use `hasErrorType` from `@outputai/core`. It walks the cause chain and matches native instances and Temporal's serialized `type` and `name` fields.

import { hasErrorType, workflow } from '@outputai/core';
import { lookupCompany } from './steps.js';
import { CompanyNotFoundError } from './types.js';

export default workflow( {
  name: 'company_lookup',
  fn: async input => {
    try {
      return await lookupCompany( input );
    } catch ( error ) {
      if ( hasErrorType( error, CompanyNotFoundError ) ) {
        return null;
      }

      throw error;
    }
  }
} );

Define custom Error classes in a shared module imported by both the workflow and step:

export class CompanyNotFoundError extends Error {}

Do not inspect a fixed number of `.cause` levels or check only the outer `ActivityFailure`.

Valid try/catch patterns

Fallback step

const fetchWithFallback = async input => {
  try {
    return await fetchFromPrimarySource( input );
  } catch {
    return fetchFromSecondarySource( input );
  }
};

Use this only when every primary-source failure should trigger the fallback. Use `hasErrorType` when only specific failures are recoverable.

Partial failures

const results = await Promise.all( input.items.map( async item => {
  try {
    return { item, value: await processItem( item ), ok: true };
  } catch ( error ) {
    const message = error instanceof Error ? error.message : String( error );
    return { item, error: message, ok: false };
  }
} ) );

Ensure the workflow output schema supports both successful and failed entries. Do not silently omit failures.

Configure Activity retries separately

Configure step and evaluator retry behavior through workflow Activity options. The workflow catch block handles only the failure that remains after this policy is exhausted.

export default workflow( {
  name: 'company_lookup',
  fn: async input => lookupCompany( input ),
  options: {
    activityOptions: {
      retry: {
        initialInterval: '1s',
        maximumAttempts: 3
      }
    }
  }
} );

Review checklist

  • Catch only when the workflow has a defined recovery path.
  • Use `hasErrorType` for specific errors originating in steps or evaluators.
  • Rethrow unmatched errors unchanged.
  • Do not replace an existing failure with a generic `Error`.
  • Keep custom Error class names stable because Temporal serializes them as failure types.
  • Configure retries independently from workflow catch behavior.
Read more
@growthxai
Ships withoutput

The open-source TypeScript framework for building AI workflows and agents. Designed for Claude Code — describe what you want, Claude builds it, with all the best practices already in place. One framework.

44451 skills5 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
444
Star history of growthxai/output on GitHub, a chart by star-history.com

Other skills on output.

output-build-workflow

output-build-workflow

Implement an Output SDK workflow from a plan document. Use when the user asks to build, implement, or code a workflow from an…

@growthxai@growthxaiInstall Skill
output-credentials-edit

output-credentials-edi…

View, edit, and set encrypted credentials in an Output.ai project. Use when adding secrets, updating API keys, verifying…

@growthxai@growthxaiInstall Skill
output-credentials-init

output-credentials-ini…

Initialize encrypted credentials for an Output.ai project. Use when setting up credentials for the first time, adding…

@growthxai@growthxaiInstall Skill
output-debug-workflow

output-debug-workflow

Debug Output SDK workflow issues. Use when user reports a workflow failing, erroring, hanging, producing wrong results, or asks…

@growthxai@growthxaiInstall Skill
output-dev-agent-class

output-dev-agent-class

Use the Agent class for multi-step tool loops, conversation history, streaming progress, and reusable LLM agents. Use when…

@growthxai@growthxaiInstall Skill

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills11d309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc12d293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react2d252k
@facebook@facebookInstall Skill

Questions about output-error-try-catch.

Which coding agents can use output-error-try-catch?
output-error-try-catch installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.