api-error-handling

仓库创建 2025年11月8日最近提交 29 天前SkillHot 收录 22 天前
▸ 精选理由

统一错误格式与日志方案,有助于运维与客户排查问题。

这个 Skill 做什么

构建标准化的 API 错误响应结构、状态码、日志与监控接入方法。

帮你把后端接口的错误统一成好读又好追踪的格式,包含 HTTP 状态码、可读的 message、requestId 和 timestamp,方便前端和监控系统处理与报警。适合上线生产 API、实现错误恢复或接入错误监控时使用。特别之处是把日志、响应和监控打通,便于快速定位问题和做可观测性的埋点。

▸ 展开 SKILL.md 英文原文

Implements standardized API error responses with proper status codes, logging, and user-friendly messages. Use when building production APIs, implementing error recovery patterns, or integrating error monitoring services.

开发编程错误处理日志API 规范通用
180
Stars
28
Forks
40
仓库内 Skill
+0
7 日增星
安装 / 使用
给你的 Agent 一句话(通用)
帮我安装这个 skill:https://raw.githubusercontent.com/secondsky/claude-skills/main/plugins/api-error-handling/skills/api-error-handling/SKILL.md
或 curl 直取 SKILL.md
curl -fsSL "https://raw.githubusercontent.com/secondsky/claude-skills/main/plugins/api-error-handling/skills/api-error-handling/SKILL.md"
SKILL.MD 节选查看完整文件 ↗
# API Error Handling

Implement robust error handling with standardized responses and proper logging.

## Standard Error Response Format

```json
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid request parameters",
    "status": 400,
    "requestId": "req_abc123",
    "timestamp": "2025-01-15T10:30:00Z",
    "details": [
      { "field": "email", "message": "Invalid email format" }
    ]
  }
}
```

## Error Class (Node.js)

```javascript
class ApiError extends Error {
  constructor(code, message, status = 500, details = null) {
    super(message);
    this.code = code;
    this.status = status;
    this.details = details;
  }

  static badRequest(message, details) {
  
via SKILL·HOT · 数据来自 GitHub 公开信息 · 原文版权归作者所有