Error Handling Patterns
Use when implementing or reviewing error handling for applications, APIs, asynchronous workflows, retries, circuit breakers, graceful degradation, or distributed-system failures.
Install
npx skills add sandbaseai/workbuddy-skill --skill error-handling-patternsgit clone --depth 1 https://github.com/sandbaseai/workbuddy-skill.git /tmp/workbuddy-skill
mkdir -p ~/.claude/skills
cp -r /tmp/workbuddy-skill/skills/error-handling-patterns ~/.claude/skills/error-handling-patternsPersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# Error Handling Patterns 建立可预测、可诊断且不会泄露数据的失败处理。先分类错误和责任边界,再选择异常、Result、错误码或 Option;错误处理应恢复可恢复故障、快速暴露程序错误,并为调用方提供稳定契约。 ## 范围和安全边界 - 默认只读审查代码、API 契约、日志策略、依赖、测试和运行指标;不触发生产故障、不重放真实请求、不改重试/熔断/告警策略。 - 错误、stack trace、请求 ID、输入摘要和上下文脱敏;不得记录 token、Cookie、密码、客户内容、完整请求体、支付信息或内部秘密。 - 只在能有意义处理时捕获错误;不要用全局 catch、空 catch、吞错或把所有异常映射为成功。 - 目标环境、错误预算、降级可接受范围、数据一致性和恢复授权必须明确;未知项标记 `unknown`。 ## 分类与边界 先区分: - 预期业务/校验失败:调用方可修正,使用稳定类型/Result 和字段级错误; - 可恢复基础设施失败:超时、限流、临时网络/依赖不可用,使用有界重试、退避、熔断或降级; - 不可恢复资源失败:内存耗尽、栈溢出、损坏状态,安全停止并报警; - 程序缺陷:断言、空引用、违反不变量,保留根因证据,不伪装成正常业务失败。 为每个跨层边界定义所有者:谁发现、谁补充上下文、谁转换协议、谁决定重试/降级、谁向用户返回错误。一次错误应在合适层记录或转换,避免每层重复日志和重复计费。 ## 异常、Result 与错误契约 异常适用于当前层无法正常继续的意外故障;Result/typed error 适用于调用方需要显式处理的预期失败;Option/Maybe 只表达“没有值”,不要隐藏错误。选择必须与语言惯例、调用图、性能和公共 API 兼容性一致。 内部错误类型至少包含稳定 code、可安全展示的 message、cause 分类、correlation ID、重试建议、HTTP/RPC 映射和敏感级别。对外消息不包含 stack trace、SQL、主机、路径或 secret;内部证据保存在受控系统并关联不可逆的请求标识。 ## 上下文、清理与异步 在错误边界补充操作、组件、版本、相关资源和脱敏 correlation ID,保留原始 cause 和链路,不重复包装同一故障。使用 `finally`、context manager、defer 或等价机制释放连接、锁、临时文件、取消令牌和 tracing span;清理失败要有独立可见状态。 异步任务必须显式等待/收集、取消和传播错误,处理超时、取消、部分完成和重入。禁止未处理 promise rejection、后台任务静默失败、竞态覆盖错误或在取消后继续写入共享状态。 ## 重试、超时、熔断和降级 仅对幂等或具备幂等键的瞬态错误重试;设置单次超时、总时限、最大次数、指数退避/抖动和预算,禁止嵌套重试造成放大。区分客户端取消、服务端超时、限流、认证失败和永久业务错误。 熔断定义 closed/open/half-open 条件、窗口、探测上限、恢复和告警;降级定义数据新鲜度、正确性、一致性和用户可接受边界。缓存、陈旧读、空结果和备用服务不能悄悄伪装成成功;对可能造成数据丢失、重复提交或安全绕过的降级默认 fail closed。 ## 可观测性与验证
Details
- Skill name
error-handling-patterns- Repository
- sandbaseai/workbuddy-skill
- Path
skills/error-handling-patterns/SKILL.md- License
- MIT
- Repo updated
- 8 September 2026
FAQ
What does the Error Handling Patterns skill do?
Use when implementing or reviewing error handling for applications, APIs, asynchronous workflows, retries, circuit breakers, graceful degradation, or distributed-system failures.
How do I install the Error Handling Patterns skill?
skills CLI (Claude Code, Cursor, Codex and more): npx skills add sandbaseai/workbuddy-skill --skill error-handling-patterns. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Error Handling Patterns popular?
It lives in sandbaseai/workbuddy-skill, which has 9 GitHub stars and 3 forks.
Related skills
Access Control Security Best Practices
9sandbaseai/workbuddy-skill
Design, review, implement, and verify least-privilege access controls across users, services, tenants, resources, and administrative workflows.
Accessibility Review
9sandbaseai/workbuddy-skill
Use when reviewing a web interface or interaction for semantic, keyboard, focus, screen-reader, ARIA, and contrast accessibility risks.
Acquire Codebase Knowledge
9sandbaseai/workbuddy-skill
Use when the user asks to map, document, or onboard into an existing codebase and needs evidence-backed architecture, structure, conventions, integrations, testing, and concerns documentation.
Meeting Notes
9sandbaseai/workbuddy-skill
把會議逐字稿整理成結構化會議記錄(決議事項/待辦與負責人/未決問題三區)。使用者貼上逐字稿、說「整理會議」「幫我整理會議記錄」時使用;一般聊天、寫程式、整理非會議文件時不要用。
Email Drafting
9sandbaseai/workbuddy-skill
Load when the user asks to draft, compose, or send an email — or to write a Telegram message that is substantively a message draft (not a quick reply).
Memory Discipline
9sandbaseai/workbuddy-skill
Use when WorkBuddy has project memory or a memory backend and must decide what to recall before acting and what durable decisions, corrections, failures, or preferences to save afterward.
Browse the most popular Claude skills, all productivity & notes skills, or write your own with the skills generator.