Agent Skills
› AjayIrkal23/agentic-mercy-10x
› backend-error-handling
backend-error-handling
GitHub定义后端错误分类、集中处理及安全日志规范。规定客户端不可见内部异常,强制使用标准错误信封与HTTP状态码映射。确保服务层抛出类型化错误,控制器统一格式化响应,并严格脱敏敏感信息。
Trigger Scenarios
定义或审查后端错误类
将领域错误映射为HTTP状态码
设计集中式错误处理逻辑
审查安全日志记录与数据脱敏行为
Install
npx skills add AjayIrkal23/agentic-mercy-10x --skill backend-error-handling -g -y
SKILL.md
Frontmatter
{
"name": "backend-error-handling",
"schema": 1,
"category": "backend",
"surfaces": [
"backend"
],
"triggers": {
"paths": [],
"intents": [
"backend"
],
"keywords": [
"backend",
"behavior",
"centralized",
"client-safe",
"defining",
"error",
"handler",
"handling",
"logging",
"mapping",
"redaction",
"safe",
"taxonomy"
]
},
"platforms": [
"linux",
"darwin",
"windows"
],
"token-cost": 482,
"description": "ALWAYS invoke when defining backend error taxonomy, centralized handler behavior, safe logging, redaction, or client-safe error mapping.",
"disable-model-invocation": false
}
Backend Error Handling
Overview
Backend failures must be structured, safe, and predictable.
This skill owns the error taxonomy, centralized handler behavior, and the rule that clients never see raw internal failures.
Use When
- Defining or reviewing backend error classes.
- Mapping domain errors to HTTP status codes.
- Designing centralized error handling.
- Reviewing safe logging and redaction behavior.
Do Not Use
- Service/controller boundary questions by themselves.
- API query semantics by themselves.
- Performance tuning without error-handling impact.
Standard Error Envelope
{
"success": false,
"error": {
"code": "ERROR_CODE",
"message": "Safe user-facing message",
"details": {}
}
}
Rules:
successmust befalseerror.codeis requiredmessagemust be safe for clientsdetailsis optional and should stay narrow
Status Code Rules
400validation401unauthorized403forbidden404not found409conflict429rate limited500internal error
Centralized Handler Rules
- Normalize internal errors into the public error envelope.
- Log safely.
- Hide stack traces and internal implementation details from clients.
- Keep controllers from building ad hoc error payloads unless they are only delegating to a shared formatter.
Service Rules
- Services throw typed domain errors.
- Services do not send transport responses.
- Services do not swallow failures silently.
Logging Rules
- Log enough context to debug.
- Do not log secrets, tokens, or sensitive payloads carelessly.
- Redact internal details before anything can surface to clients.
Combine With
api-contract-standardsfor envelope compatibility.service-layer-standardsfor where errors should originate.
References
- Use
references/full-guide.mdfor the longer strict version with class patterns and more detailed rules.
Version History
- 581d130 Current 2026-07-19 09:04


