Token导航 LogoToken导航

Agent Skill · 研究检索

error-handling(错误处理)

error-handling 用于记录任务执行中的错误、用户纠正、经验和能力缺口,适合在 Codex、Claude、Cursor、Gemini CLI 中希望让 Agent 持续沉淀问题、修正和最佳实践时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

error-handling 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为调用外部服务;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 64,698。

总安装 294周安装 12GitHub Stars 4下载 94核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:error-handling(错误处理)
来源仓库:https://github.com/accolver/skill-maker
仓库路径:skills/error-handling
安装命令:
npx skills add https://github.com/accolver/skill-maker --skill error-handling
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/accolver/skill-maker --skill error-handling

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

error-handling 标准化错误处理模式,建立统一的错误分类、编码与传播机制,提升系统可观测性与调试效率。适用于需要统一错误模型、日志格式和响应结构的场景,解决跨层不一致问题。将错误拆分为用户友好提示与详细内部记录,支持追踪与关联分析。

安装命令为 npx skills add https://github.com/accolver/skill-maker --skill error-handling,需写入配置或代码文件权限。注意:不适用于单次故障排查,而是构建长期稳定的错误处理框架。

来源仓库内路径:skills/error-handling

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/accolver/skill-maker --skill error-handling;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要调用外部服务,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

error-handling 怎么安装?

在终端执行 npx skills add https://github.com/accolver/skill-maker --skill error-handling。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

error-handling 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

error-handling 需要什么权限?

权限级别是调用外部服务。该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

error-handling 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

error-handling 用的人多吗?

公开数据是累计安装 294 次,近一周安装 12 次,下载 94 次,GitHub 4 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

error-handling 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
error-handling

错误处理 · 本页

2944调用外部服务未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Error Handling

Overview

Standardize error handling across a codebase by implementing a unified error taxonomy, stable error codes, proper propagation chains, and structured logging. The core principle: every error must be categorized, coded, wrapped with context, and split into a safe user-facing message and a detailed internal log entry.

When to use

  • The task is to standardize how an existing codebase models, propagates, logs, and returns errors.
  • The user needs an error taxonomy, error classes, response envelopes, or correlation-aware logging patterns.
  • The problem is inconsistency across layers, services, or endpoints rather than a single failing bug.
  • The deliverable is an error-handling framework or pattern, not one-off troubleshooting.

Do NOT use when:

  • The task is debugging a specific runtime failure.
  • The request is about monitoring, alert routing, or dashboards rather than application error design.
  • The work is only input validation or business rules with no broader error-model concern.

Response format

Always structure the final response with these top-level sections, in this order:

  1. Summary — state the task, scope, and main conclusion in 1-3 sentences.
  2. Decision / Approach — state the key classification, assumptions, or chosen path.
  3. Artifacts — provide the primary deliverable(s) for this skill. Use clear subheadings for multiple files, commands, JSON payloads, queries, or documents.
  4. Validation — state checks performed, important risks, caveats, or unresolved questions.
  5. Next steps — list concrete follow-up actions, or write None if nothing remains.

Rules:

  • Do not omit a section; write None when a section does not apply.
  • If files are produced, list each file path under Artifacts before its contents.
  • If commands, JSON, SQL, YAML, or code are produced, put each artifact in fenced code blocks with the correct language tag when possible.
  • Keep section names exactly as written above so output stays predictable across skills.

Workflow

1. Audit existing error handling

Scan the codebase for current error patterns:

  • Search for try/catch, try/except, .catch(), rescue, error middleware
  • Identify swallowed exceptions (empty catch blocks, catch-and-ignore)
  • Find bare throws/raises without context wrapping
  • Note inconsistent error response formats across endpoints
  • Check for leaked internal details in user-facing responses

Output: A list of error handling gaps and inconsistencies.

2. Define the error taxonomy

Create error categories that map to HTTP status codes (for APIs) or exit conditions (for services). Every error in the system must belong to exactly one category.

CategoryHTTP StatusError Code PrefixDescription
validation400ERR_VALIDATION_Invalid input, malformed request
authentication401ERR_AUTH_Missing or invalid credentials
authorization403ERR_FORBIDDEN_Valid credentials but insufficient access
not_found404ERR_NOT_FOUND_Requested resource does not exist
conflict409ERR_CONFLICT_State conflict (duplicate, version mismatch)
rate_limit429ERR_RATE_LIMIT_Too many requests
internal500ERR_INTERNAL_Unexpected server error
service_unavailable503ERR_UPSTREAM_Dependency failure (DB, external API)

3. Implement error class hierarchy

Create a base error class and category-specific subclasses. Every error class must carry:

  • code — Stable string code clients can match on (e.g., ERR_USER_NOT_FOUND)
  • message — Safe, user-facing message (no stack traces, no internal paths)
  • statusCode — HTTP status code for API responses
  • category — Error taxonomy category
  • details — Optional structured data (field validation errors, constraints)
  • cause — Original error for propagation chain (preserves stack trace)

TypeScript example:

export class AppError extends Error {
  public readonly code: string;
  public readonly statusCode: number;
  public readonly category: string;
  public readonly details?: Record<string, unknown>;
  public readonly isOperational: boolean;

  constructor(params: {
    code: string;
    message: string;
    statusCode: number;
    category: string;
    details?: Record<string, unknown>;
    cause?: Error;
    isOperational?: boolean;
  }) {
    super(params.message, { cause: params.cause });
    this.code = params.code;
    this.statusCode = params.statusCode;
    this.category = params.category;
    this.details = params.details;
    this.isOperational = params.cause !== undefined
      ? true
      : (params.isOperational ?? true);
    this.name = this.constructor.name;
    Error.captureStackTrace(this, this.constructor);
  }
}

export class ValidationError extends AppError {
  constructor(
    message: string,
    details?: Record<string, unknown>,
    cause?: Error,
  ) {
    super({
      code: "ERR_VALIDATION",
      message,
      statusCode: 400,
      category: "validation",
      details,
      cause,
    });
  }
}

export class NotFoundError extends AppError {
  constructor(resource: string, identifier: string, cause?: Error) {
    super({
      code: `ERR_NOT_FOUND_${resource.toUpperCase()}`,
      message: `${resource} not found`,
      statusCode: 404,
      category: "not_found",
      details: { resource, identifier },
      cause,
    });
  }
}

export class ConflictError extends AppError {
  constructor(
    message: string,
    details?: Record<string, unknown>,
    cause?: Error,
  ) {
    super({
      code: "ERR_CONFLICT",
      message,
      statusCode: 409,
      category: "conflict",
      details,
      cause,
    });
  }
}

export class AuthenticationError extends AppError {
  constructor(message = "Authentication required", cause?: Error) {
    super({
      code: "ERR_AUTH_INVALID",
      message,
      statusCode: 401,
      category: "authentication",
      cause,
    });
  }
}

export class AuthorizationError extends AppError {
  constructor(message = "Insufficient permissions", cause?: Error) {
    super({
      code: "ERR_FORBIDDEN",
      message,
      statusCode: 403,
      category: "authorization",
      cause,
    });
  }
}

export class RateLimitError extends AppError {
  constructor(retryAfterSeconds?: number, cause?: Error) {
    super({
      code: "ERR_RATE_LIMIT",
      message: "Too many requests",
      statusCode: 429,
      category: "rate_limit",
      details: retryAfterSeconds
        ? { retryAfter: retryAfterSeconds }
        : undefined,
      cause,
    });
  }
}

export class InternalError extends AppError {
  constructor(message: string, cause?: Error) {
    super({
      code: "ERR_INTERNAL",
      message: "An unexpected error occurred",
      statusCode: 500,
      category: "internal",
      cause,
      isOperational: false,
    });
  }
}

Python equivalent:

class AppError(Exception):
    def __init__(
        self,
        code: str,
        message: str,
        status_code: int,
        category: str,
        details: dict | None = None,
        cause: Exception | None = None,
        is_operational: bool = True,
    ):
        super().__init__(message)
        self.code = code
        self.message = message
        self.status_code = status_code
        self.category = category
        self.details = details or {}
        self.is_operational = is_operational
        self.__cause__ = cause

class NotFoundError(AppError):
    def __init__(self, resource: str, identifier: str, cause: Exception | None = None):
        super().__init__(
            code=f"ERR_NOT_FOUND_{resource.upper()}",
            message=f"{resource} not found",
            status_code=404,
            category="not_found",
            details={"resource": resource, "identifier": identifier},
            cause=cause,
        )

class ValidationError(AppError):
    def __init__(self, message: str, details: dict | None = None, cause: Exception | None = None):
        super().__init__(
            code="ERR_VALIDATION",
            message=message,
            status_code=400,
            category="validation",
            details=details,
            cause=cause,
        )

4. Implement error propagation rules

Never swallow exceptions. Every catch block must either:

  1. Re-raise the error unchanged (if this layer can't add context)
  2. Wrap the error in a domain-specific error with the original as cause
  3. Handle the error completely (log it, return a response, trigger recovery)

Always preserve the chain. When wrapping, pass the original error as cause so the full stack trace is available in logs:

// WRONG: swallows the original error
try {
  await db.query(sql);
} catch (err) {
  throw new Error("Database query failed"); // original error lost
}

// RIGHT: wraps with context, preserves cause
try {
  await db.query(sql);
} catch (err) {
  throw new InternalError("Database query failed", err as Error);
}

5. Separate user-facing from internal errors

User-facing response — safe, minimal, actionable:

{
  "error": {
    "code": "ERR_NOT_FOUND_USER",
    "message": "User not found",
    "details": {
      "resource": "user",
      "identifier": "usr_abc123"
    }
  },
  "requestId": "req_7f3a2b1c"
}

Internal log entry — full diagnostic context:

{
  "level": "error",
  "code": "ERR_NOT_FOUND_USER",
  "message": "User not found",
  "category": "not_found",
  "correlationId": "req_7f3a2b1c",
  "userId": "usr_abc123",
  "path": "/api/users/usr_abc123",
  "method": "GET",
  "stack": "NotFoundError: User not found\n    at UserService.getById ...",
  "cause": "MongoError: connection refused at 10.0.0.5:27017",
  "timestamp": "2026-03-06T10:15:32.456Z",
  "service": "user-api",
  "environment": "production"
}

Rules:

  • Never expose stack traces, file paths, or database errors to users
  • Never expose internal service names or infrastructure details
  • Always include the error code in both user response and log
  • Always include a requestId / correlationId in both
  • Log the full causal chain internally; show only the top-level message to users
  • For InternalError (500), always use a generic message: "An unexpected error occurred"

6. Implement error response middleware

Centralize error-to-response conversion in middleware (Express) or exception handlers (FastAPI, Django). This is the single place where errors become HTTP responses.

// Express error middleware
function errorHandler(
  err: Error,
  req: Request,
  res: Response,
  next: NextFunction,
) {
  const correlationId = req.headers["x-request-id"] || crypto.randomUUID();

  if (err instanceof AppError) {
    // Operational error — expected, safe to expose
    logger.error({
      code: err.code,
      message: err.message,
      category: err.category,
      correlationId,
      path: req.path,
      method: req.method,
      stack: err.stack,
      cause: err.cause?.message,
    });

    return res.status(err.statusCode).json({
      error: {
        code: err.code,
        message: err.message,
        ...(err.details && { details: err.details }),
      },
      requestId: correlationId,
    });
  }

  // Unexpected error — do NOT expose details
  logger.error({
    code: "ERR_INTERNAL",
    message: err.message,
    category: "internal",
    correlationId,
    path: req.path,
    method: req.method,
    stack: err.stack,
  });

  return res.status(500).json({
    error: {
      code: "ERR_INTERNAL",
      message: "An unexpected error occurred",
    },
    requestId: correlationId,
  });
}

7. Add structured error logging

Every error log entry must include:

FieldRequiredDescription
levelYeserror, warn, or fatal
codeYesStable error code (e.g., ERR_NOT_FOUND_USER)
messageYesHuman-readable description
categoryYesError taxonomy category
correlationIdYesRequest ID for tracing across services
pathYesRequest path or operation name
methodYesHTTP method or operation type
stackYesFull stack trace
causeNoOriginal error message if wrapped
timestampYesISO 8601 timestamp
serviceYesService name for multi-service architectures
userIdNoAuthenticated user ID if available
detailsNoStructured error details (validation fields)

Checklist

  • Error taxonomy defined with categories mapping to HTTP status codes
  • Base error class implemented with code, message, statusCode, category, cause
  • Category-specific error subclasses created (validation, auth, not-found, etc.)
  • Error codes are stable strings clients can match on programmatically
  • All catch blocks either re-raise, wrap with context, or fully handle
  • No swallowed exceptions (empty catch blocks)
  • User-facing responses contain only code, message, and safe details
  • Internal logs contain full stack traces, causal chains, and request context
  • Correlation ID flows through from request to response to logs
  • Centralized error middleware converts errors to consistent HTTP responses
  • 500 errors always use generic message, never expose internals

Error Response Schema

All API error responses must follow this schema:

{
  "error": {
    "code": "ERR_VALIDATION",
    "message": "Invalid email format",
    "details": {
      "field": "email",
      "constraint": "Must be a valid email address",
      "received": "not-an-email"
    }
  },
  "requestId": "req_7f3a2b1c"
}
FieldTypeRequiredDescription
error.codestringYesStable error code for programmatic matching
error.messagestringYesHuman-readable description, safe for users
error.detailsobjectNoStructured context (validation fields, etc.)
requestIdstringYesCorrelation ID for support and debugging

Common mistakes

MistakeFix
Swallowing exceptions in empty catch blocksEvery catch must re-raise, wrap, or fully handle. Log at minimum.
Leaking stack traces to API consumersError middleware must strip internals. Only expose code + message + safe details.
Using HTTP status codes as error codesStatus codes are transport-level. Use stable string codes (ERR_USER_NOT_FOUND) for programmatic use.
Inconsistent error response formatCentralize in error middleware. Every error response uses the same JSON schema.
Throwing raw strings instead of error objectsAlways throw typed error instances with code, category, and cause chain.
Missing correlation IDsGenerate a request ID at the edge (middleware/gateway) and propagate through all layers and logs.
Logging user-facing message onlyInternal logs must include stack trace, cause chain, request context, and correlation ID.
Different error formats per endpointOne error middleware, one response schema. Endpoints throw typed errors; middleware formats responses.
Catching too broadly (catch Exception)Catch specific error types when possible. Use broad catch only at the top-level error boundary.
Not distinguishing operational vs programmer errorsOperational errors (bad input, not found) are expected. Programmer errors (null deref) need alerts.

Key principles

  1. Every error gets a stable code — HTTP status codes change meaning across contexts. String error codes like ERR_USER_NOT_FOUND are stable contracts that clients, monitoring, and documentation can rely on. Never use numeric codes alone.
  2. Never swallow, always wrap — Empty catch blocks hide bugs. Every caught error must be re-raised, wrapped with domain context (preserving the original as cause), or fully handled. The causal chain must survive from origin to log.
  3. User-facing and internal are separate concerns — Users see a safe message and an error code. Logs see the full stack trace, causal chain, correlation ID, and request context. The error middleware is the boundary between these two worlds.
  4. Correlation IDs connect everything — A single request ID generated at the edge must appear in the HTTP response, every log entry, and any downstream service calls. Without this, debugging production errors across services is impossible.
  5. Centralize the error boundary — One error middleware, one response schema, one logging format. Individual endpoints throw typed errors; they never format error responses directly. This eliminates inconsistency.

平台分布

Codex

34.95%
按下载量换算33

Claude

28.47%
按下载量换算27

Cursor

18.46%
按下载量换算17

Gemini CLI

8.88%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

调用外部服务

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills