xiaohongshu
xiaohongshu
flow-error-try-catch-removal
Remove try-catch antipattern from step calls during Flow to Output SDK migration. Use when converting workflow code that wraps step calls in try-catch blocks.
Full skill instructions
This skill helps identify and remove the try-catch antipattern that's common in Flow SDK code but incorrect in Output SDK. In Output SDK, step calls should NOT be wrapped in try-catch blocks - errors should propagate up the chain.
During Migration:
Code Patterns to Fix:
In Output SDK, the workflow execution engine handles errors automatically:
// WRONG: Wrapping step calls in try-catch
export default workflow( {
name: 'someWorkflow',
description: 'a workflow description',
inputSchema: WorkflowInputSchema,
outputSchema: WorkflowOutputSchema,
fn: async input => {
try {
// Step 1: Get User data
const userData = await getUserData( { userId: input.userId } );
// Step 2: Get role configuration
const roleConfig = await getRoleConfig( { role: userData.role } );
// Step 3: Ensure something
await ensureSomething( { config: roleConfig } );
return { success: true };
} catch ( error ) {
throw new FatalError( error instanceof Error ? error.message : 'Unknown workflow error' );
}
}
} );
// CORRECT: Let errors propagate naturally
export default workflow( {
name: 'someWorkflow',
description: 'a workflow description',
inputSchema: WorkflowInputSchema,
outputSchema: WorkflowOutputSchema,
fn: async input => {
// Step 1: Get User data
const userData = await getUserData( { userId: input.userId } );
// Step 2: Get role configuration
const roleConfig = await getRoleConfig( { role: userData.role } );
// Step 3: Ensure something
await ensureSomething( { config: roleConfig } );
return { success: true };
}
} );
Search for try-catch patterns in workflow files:
grep -r "try {" src/workflows/*/workflow.ts
grep -r "} catch" src/workflows/*/workflow.ts
Before removing, understand what the try-catch was doing:
Remove the try-catch wrapper but keep the step calls:
// Before
fn: async input => {
try {
const result = await someStep( input );
return result;
} catch ( error ) {
throw new FatalError( error.message );
}
}
// After
fn: async input => {
const result = await someStep( input );
return result;
}
Try-catch is still appropriate in specific cases:
Steps can use try-catch for internal logic:
export const fetchExternalData = step( {
name: 'fetchExternalData',
inputSchema: z.object( { url: z.string() } ),
fn: async ( input ) => {
try {
const response = await fetch( input.url );
return response.json();
} catch ( error ) {
// Transform to ValidationError for expected failures
throw new ValidationError( `Failed to fetch: ${input.url}` );
}
}
} );
When you need to handle a specific error type differently:
fn: async input => {
const userData = await getUserData( { userId: input.userId } );
try {
await sendNotification( { userId: userData.id } );
} catch ( error ) {
// Only catch specific expected errors
if ( error instanceof NotificationDisabledError ) {
// User has notifications disabled - continue without notification
console.log( 'Notifications disabled for user' );
} else {
throw error; // Re-throw unexpected errors
}
}
return { success: true };
}
When a failure shouldn't stop the workflow:
fn: async input => {
const result = await processData( input );
// Optional: try to cache result, but don't fail if caching fails
try {
await cacheResult( { key: input.id, value: result } );
} catch {
// Caching failed - log but continue
console.warn( 'Failed to cache result' );
}
return result;
}
import { FatalError } from '@flow/sdk';
import { getUserData, processUser, saveResults } from './activities';
export default class UserProcessingWorkflow {
async execute(input: WorkflowInput): Promise<WorkflowOutput> {
try {
const user = await getUserData(input.userId);
const processed = await processUser(user);
await saveResults(processed);
return { success: true, userId: user.id };
} catch (error) {
throw new FatalError(`Workflow failed: ${error.message}`);
}
}
}
import { workflow, z } from '@output.ai/core';
import { getUserData, processUser, saveResults } from './steps.js';
import { WorkflowInputSchema, WorkflowOutputSchema } from './types.js';
export default workflow( {
name: 'userProcessing',
description: 'Process user data',
inputSchema: WorkflowInputSchema,
outputSchema: WorkflowOutputSchema,
fn: async input => {
const user = await getUserData( { userId: input.userId } );
const processed = await processUser( { user } );
await saveResults( { data: processed } );
return { success: true, userId: user.id };
}
} );
# Should return minimal results (only appropriate uses)
grep -A5 "try {" src/workflows/*/workflow.ts
npx output workflow run <workflowName> --input '{}'
Intentionally trigger an error to verify it propagates correctly.
flow-convert-workflow-definition - Full workflow conversionflow-convert-activities-to-steps - Step conversion patternsflow-validation-checklist - Complete migration validationxiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience