output-error-try-catch
Fix try-catch anti-pattern in Output SDK workflows. Use when retries aren't working, errors are being swallowed, seeing unexpected FatalError wrapping, or when step failures don't trigger retry policies.
What this skill does
# Fix Try-Catch Anti-Pattern
## Overview
This skill helps diagnose and fix a common anti-pattern where step calls are wrapped in try-catch blocks. This prevents Output SDK's retry mechanism from working properly and can lead to confusing error behavior.
## When to Use This Skill
You're seeing:
- Retries not working as expected
- Errors being swallowed silently
- Unexpected FatalError wrapping
- Step failures not triggering retry policies
- Errors being caught and re-thrown incorrectly
## Root Cause
When you wrap step calls in try-catch blocks, you intercept errors before the Output SDK retry mechanism can handle them. This defeats the built-in retry logic and can cause:
1. **Retries not happening**: The error is caught, so the framework doesn't know to retry
2. **Wrong error classification**: Re-throwing as FatalError prevents retries entirely
3. **Lost error context**: Original error details may be lost in the catch block
## Symptoms
### Pattern 1: Errors Swallowed
```typescript
// WRONG: Error is silently ignored
try {
const result = await myStep( input );
} catch ( error ) {
console.log( 'Step failed' ); // Swallowed!
return { success: false };
}
```
### Pattern 2: FatalError Wrapping
```typescript
// WRONG: Turns retryable errors into fatal errors
try {
const result = await myStep( input );
} catch ( error ) {
throw new FatalError( error.message ); // Prevents retries!
}
```
### Pattern 3: Re-throwing Generic Errors
```typescript
// WRONG: Loses error context and may affect retry behavior
try {
const result = await myStep( input );
} catch ( error ) {
throw new Error( `Step failed: ${error.message}` );
}
```
## Solution
**Let failures propagate naturally.** Remove try-catch blocks around step calls and let the Output SDK handle errors:
### Before (Wrong)
```typescript
export default workflow( {
fn: async input => {
try {
const data = await fetchDataStep( input );
const result = await processDataStep( data );
return result;
} catch ( error ) {
throw new FatalError( error.message );
}
}
} );
```
### After (Correct)
```typescript
export default workflow( {
fn: async input => {
const data = await fetchDataStep( input );
const result = await processDataStep( data );
return result;
}
} );
```
## When Try-Catch IS Appropriate
There are limited cases where catching errors in workflows is valid:
### 1. Optional/Fallback Steps
When a step failure should trigger an alternative path:
```typescript
export default workflow( {
fn: async input => {
const data = await ( async () => {
try {
return await fetchFromPrimarySource( input );
} catch {
return await fetchFromSecondarySource( input );
}
} )();
return await processData( data );
}
} );
```
For readability, you can extract the fallback logic into a named helper function instead of using an IIFE:
```typescript
const fetchWithFallback = async input => {
try {
return await fetchFromPrimarySource( input );
} catch {
return await fetchFromSecondarySource( input );
}
};
export default workflow( {
fn: async input => {
const data = await fetchWithFallback( input );
return await processData( data );
}
} );
```
### 2. Aggregate Results with Partial Failures
When processing multiple items where some may fail:
```typescript
export default workflow( {
fn: async input => {
const results = [];
for ( const item of input.items ) {
try {
const result = await processItem( item );
results.push( { item, result, success: true } );
} catch ( error ) {
results.push( { item, error: error.message, success: false } );
}
}
return results; // Contains both successes and failures
}
} );
```
**Note**: Even in these cases, be careful not to swallow errors that should cause the whole workflow to fail.
## Finding Try-Catch Around Steps
Search for the pattern:
```bash
# Find try blocks in workflow files
grep -rn "try {" src/workflows/
# Look for FatalError usage
grep -rn "FatalError" src/workflows/
```
Then review each match to see if it's wrapping step calls.
## How Retries Work
When you DON'T catch errors:
1. Step throws an error
2. Output SDK receives the error
3. SDK checks retry policy (configured per step)
4. If retries remain, step is re-executed
5. If retries exhausted, workflow fails with full error context
When you DO catch errors:
1. Step throws an error
2. Your catch block handles it
3. Output SDK never sees the original error
4. Retry logic is bypassed
5. You control what happens (often incorrectly)
## Configuring Retry Behavior
Instead of try-catch, configure retry policies on steps:
```typescript
export const fetchData = step( {
name: 'fetchData',
retry: {
maxAttempts: 3,
initialInterval: '1s',
maxInterval: '30s',
backoffCoefficient: 2
},
fn: async input => {
// If this fails, it will be retried according to policy
return await callApi( input );
}
} );
```
## Using FatalError Correctly
FatalError is for errors that should NEVER be retried:
```typescript
export const validateInput = step( {
name: 'validateInput',
fn: async input => {
if ( !input.userId ) {
// This will never succeed on retry
throw new FatalError( 'userId is required' );
}
return input;
}
} );
```
Do NOT use FatalError to wrap other errors unless you're certain they shouldn't retry.
## Verification
After removing try-catch:
1. **Test normal operation**: `npx output workflow run <name> '<valid-input>'`
2. **Test failure scenarios**: Use input that causes step failures
3. **Check retry behavior**: Look for retry attempts in `npx output workflow debug <id>`
## Related Issues
- For configuring retry policies, see step definition documentation
- For handling expected failures gracefully, consider using conditional logic instead of try-catch
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.