Agent Skillshellowind777/helloagents › hello-errors

hello-errors

GitHub

规范错误处理、日志记录、监控及重试降级机制,确保结构化错误格式与安全脱敏,防止静默失败。

skills/hello-errors/SKILL.md hellowind777/helloagents

Trigger Scenarios

实现异常捕获与处理逻辑 配置日志记录与监控策略 设计重试与降级恢复机制

Install

npx skills add hellowind777/helloagents --skill hello-errors -g -y
More Options

Use without installing

npx skills use hellowind777/helloagents@hello-errors

指定 Agent (Claude Code)

npx skills add hellowind777/helloagents --skill hello-errors -a claude-code -g -y

安装 repo 全部 skill

npx skills add hellowind777/helloagents --all -g -y

预览 repo 内 skill

npx skills add hellowind777/helloagents --list

SKILL.md

Frontmatter
{
    "name": "hello-errors",
    "description": "实现错误处理、try-catch、日志记录、监控、重试逻辑、降级机制,或处理错误响应和异常管理时使用。"
}

错误处理相关代码必须遵循以下规范。

编码前

先分类可预期错误 vs 不可预期错误,再写代码。

错误分类

  • 可预期错误(验证失败、资源不存在)→ 正常处理,返回友好信息
  • 不可预期错误(系统故障、第三方宕机)→ 记录日志,返回通用错误
  • 不要用 try-catch 包裹所有代码——只捕获你能处理的

结构化错误

  • 统一错误格式:{ code, message, details? }
  • HTTP 状态码准确:4xx 客户端错误,5xx 服务端错误
  • 不暴露内部实现细节(堆栈、SQL、文件路径)给用户
  • 错误码可枚举,便于前端处理

日志规范

  • 结构化日志(JSON),包含 timestamp、level、context
  • 错误日志包含:堆栈、请求 ID、用户上下文
  • 敏感信息脱敏后再记录(密码、token、身份证)
  • 日志级别:error(必须处理)> warn(需关注)> info(正常流程)> debug(调试)

恢复策略

  • 外部调用:超时 + 重试(指数退避,最多 3 次)
  • 关键操作:幂等设计,支持安全重试
  • 优雅降级:部分功能不可用时不影响核心流程
  • 断路器:连续失败超过阈值时快速失败

交付检查

  • 错误响应格式统一
  • 不暴露内部细节给用户
  • 外部调用有超时设置
  • 敏感信息已脱敏
  • 无静默失败:无空 catch 吞错误、无静默降级、无静默回退(见 HelloAGENTS“失败处理”)

Version History

  • 79c0b48 Current 2026-08-20 08:25

Same Skill Collection

skills/commands/auto/SKILL.md
skills/commands/loop/SKILL.md
skills/hello-api/SKILL.md
skills/hello-data/SKILL.md
skills/hello-perf/SKILL.md
skills/hello-security/SKILL.md
skills/hello-test/SKILL.md
skills/hello-ui/SKILL.md
skills/hello-write/SKILL.md
skills/_meta/SKILL.md
skills/commands/ask/SKILL.md
skills/commands/clean/SKILL.md
skills/commands/commit/SKILL.md
skills/commands/help/SKILL.md
skills/commands/init/SKILL.md
skills/commands/plan/SKILL.md
skills/commands/prd/SKILL.md
skills/commands/qa/SKILL.md
skills/commands/test/SKILL.md
skills/hello-arch/SKILL.md
skills/hello-debug/SKILL.md
skills/hello-reflect/SKILL.md
skills/hello-subagent/SKILL.md
skills/helloagents/SKILL.md
skills/qa-review/SKILL.md

Metadata

Files
0
Version
79c0b48
Hash
ab1c0c48
Indexed
2026-08-20 08:25

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-25 05:49
浙ICP备14020137号-1 $방문자$