error-handling-patterns

error-handling-patterns is a skill for Claude Code, Codex from cass-2003/local-workflow-skill. It costs 113 tokens per session (3,431 once invoked), scanned A, original, MIT.

A guide to deciding how software should report, pass along, and recover from errors. It covers exceptions, returned error values, error details, retries, and circuit breakers, which stop repeated calls to a failing service.

In plain words
What is it for?
Use it when designing library or API errors, handling database and network failures, preserving stack traces, or choosing retry and fallback behavior.
Why use it?
It prevents errors from being hidden or stripped of useful context. It also helps distinguish temporary failures that may be retried from permanent failures that need a different response.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when designing library or API errors, handling database and network failures, preserving stack traces, or choosing retry and fallback behavior.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/cass-2003/local-workflow-skill/error-handling-patterns
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add cass-2003/local-workflow-skill --skill error-handling-patterns
Clone the repo
git clone --depth 1 https://github.com/cass-2003/local-workflow-skill

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for error-handling-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/cass-2003/local-workflow-skill/error-handling-patterns/github.svg)](https://agentmods.dev/skills/cass-2003/local-workflow-skill/error-handling-patterns)
Your own site
<a href="https://agentmods.dev/skills/cass-2003/local-workflow-skill/error-handling-patterns"><img src="https://agentmods.dev/badge/skills/cass-2003/local-workflow-skill/error-handling-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for error-handling-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/cass-2003/local-workflow-skill/error-handling-patterns"><img src="https://agentmods.dev/badge/skills/cass-2003/local-workflow-skill/error-handling-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 113 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,431 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00113 $0.03431
Opus 5 $0.00056 $0.01716
Sonnet 5 $0.00023 $0.00686
Haiku 4.5 $0.00011 $0.00343

Measured 7d ago against content hash 265185958c4c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

error-handling-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/engineering-core/ours/error-handling-patterns/SKILL.md · 377 lines

How it starts

The opening of the file, as written. The whole thing — 377 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Error Handling Patterns Skill — 错误处理跨语言

何时使用

  • 设计公共库 / SDK 的错误 API
  • 调试"日志写了但堆栈没了"/ "错误吞了没人知道"
  • 跨服务调用错误传递(HTTP / gRPC)
  • 决定何时 throw / 何时返回 error / 何时 panic
  • 重试 / 熔断 / 降级策略

一、错误的两个维度

维度 取值
方向 上游传来 / 自家产生 / 下游返回
可恢复性 可重试(瞬时) / 不可重试(永久) / 灾难(停服)
              | 可重试        | 不可重试       | 灾难
--------------|---------------|----------------|----------
用户输入错    | -             | 400/422 显示   | -
认证失败      | -             | 401 引导登录   | -
权限不足      | -             | 403 提示       | -
不存在        | -             | 404 提示       | -
冲突          | (有时可)      | 409 让用户改   | -
限流          | 重试退避      | -              | -
依赖超时      | 重试 1-2 次   | 降级           | -
依赖 5xx      | 重试退避      | 降级           | -
DB 死锁       | 立即重试      | -              | -
DB 连不上     | 重试退避      | -              | 启动失败 panic
代码 bug      | -             | 500 + 告警     | -
OOM           | -             | -              | crash + restart

二、四大流派

1. Exception(Java / C# / Python / Ruby / JS)

try {
  const user = await db.findUser(id)
  if (!user) throw new NotFoundError('user', id)
  return user
} catch (e) {
  if (e instanceof NotFoundError) return null
  throw e   // rethrow 未知错误
}

优点:调用栈自动展开 / 不污染正常路径 缺点:函数签名隐藏失败可能 / 容易吞噬 / 性能(构造 stack)

2. Error Value(Go)

user, err := db.FindUser(id)
if err != nil {
    if errors.Is(err, sql.ErrNoRows) { return nil, nil }
    return nil, fmt.Errorf("db.FindUser: %w", err)   // wrap
}
return user, nil

优点:错误是显式返回值 / 不会忘记处理 缺点:样板代码多 / 容易 if err != nil { return err } 丢失上下文

3. Result/Either(Rust / Haskell / Scala / 现代 TS)

fn find_user(id: u64) -> Result<User, FindError> {
    db.find_user(id).map_err(FindError::DbError)
}

match find_user(123) {
    Ok(user) => println!("{}", user.name),
    Err(FindError::DbError(e)) => log::error!("db: {}", e),
    Err(FindError::NotFound) => println!("not found"),
}
// TS / fp-ts / neverthrow
import { Result, ok, err } from 'neverthrow'

function findUser(id: number): Result<User, FindError> {
  return db.findUser(id).match(
    user => user ? ok(user) : err({ kind: 'not_found' }),
    e => err({ kind: 'db_error', cause: e })
  )
}

Read the full file on GitHub · 377 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 7d ago First seen · 377 lines · 113 tokens per session scan A 265185958c4c

Subscribe to this mod's changes

error-handling-patterns is a skill published in the GitHub repository cass-2003/local-workflow-skill (12 stars, last pushed 2mo ago), licensed MIT. It adds 113 tokens to every session and 3,431 once invoked, about $0.0006 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

printing-press-amend

Amend a published CLI from one of two input sources: (1) dogfood mode mines the active Claude Code session transcript for friction (missing flags, hand- rolled API payloads, silent-null returns); (2) direct-input mode accepts user-supplied asks (rename a command, add commands or feeds, fix a named bug, optionally…

mvanhorn/cli-printing-press · 222 tokens

convex-performance-audit

Audits Convex performance for reads, subscriptions, write contention, and function limits. Use for slow features, insights findings, OCC conflicts, or read amplification.

openclaw/clawhub · 38 tokens

convex-insights

Query a running Convex app's logs + health in natural language (official MCP): failures, slow/expensive functions, deploy causality — scoped, evidence-backed, with a dashboard deep link.

openclaw/clawhub · 45 tokens

ssl-proxy-troubleshoot

Systematic workflow for troubleshooting SSL/proxy connectivity issues with government websites.

HKUDS/OpenSpace · 20 tokens

diagnose-backend-bug

Diagnose a bounded backend or multi-service failure from GitHub Issues, Jira, Aone, user-provided exports, logs, traces, responses, stack traces, or job records. Use when a service, API, RPC, worker, queue, CLI, or scheduled job bug needs correlation through the project's existing observability route before repair; do…

QoderAI/better-harness · 87 tokens

axiom-networking

Use when implementing or debugging ANY network connection, API call, or socket. Covers URLSession, Network.framework, NetworkConnection, connection diagnostics.

CharlesWiltgen/Axiom · 33 tokens