API Error Handler 技能:统一返回可追踪的问题详情
EnglishClaude Code 安装步骤
- 从 GitHub 固定提交获取完整的 `plugins/api-development/api-error-handler/skills/handling-api-errors` 目录。
- 复制到目标项目的 `.claude/skills/`,确认 `.claude/skills/handling-api-errors/SKILL.md`,再从项目根目录启动 Claude Code,输入 `/handling-api-errors`。
中文摘要
用 Claude Code 集中处理 API 异常,映射 HTTP 状态与稳定错误类型,为前端提供可区分的错误信息和请求标识。
SKILL.md 中文导读
可复现示例
测试 GET /products/7 正常返回商品、GET /products/-1 因参数无效返回 400、GET /products/999 返回 404。检查错误响应的 type、title、status 和项目约定的 requestId。工作步骤
- 把输入校验和资源缺失映射成明确状态。集中中间件生成一致响应结构。
- 用正常请求、无效输入和缺失资源测试错误映射,核对内容类型及请求标识。
验收方法
三条请求的状态分别为 200、400、404。两个错误拥有可区分 type 与可在日志查询的请求标识。
GitHub 原文 · 更新日期
适用环境
准备自己维护的本地 API、测试客户端和统一错误字段约定。示例使用 application/problem+json。
常见问题
客户端应该用可读的 title 判断错误分支吗?
用约定稳定的 type 或业务错误码做程序判断。把 title 用于用户可读显示。
相关指南
相关推荐
groq-install-auth 技能
jeremylongshore/claude-code-plugins-plus-skills
anima-common-errors 技能
jeremylongshore/claude-code-plugins-plus-skills
apple-notes-hello-world 技能
jeremylongshore/claude-code-plugins-plus-skills
castai-hello-world 技能
jeremylongshore/claude-code-plugins-plus-skills
cohere-local-dev-loop 技能
jeremylongshore/claude-code-plugins-plus-skills
figma-security-basics 技能
jeremylongshore/claude-code-plugins-plus-skills