AgentSkillsCN

error-taxonomy

对各类错误进行分类,并制定一致的处理策略。确保合理的错误边界、面向用户的提示信息,以及完善的日志记录机制。

SKILL.md
--- frontmatter
name: error-taxonomy
description: Categorizes errors and defines consistent handling strategies. Ensures proper error boundaries, user-facing messages, and logging.

Error Taxonomy (The Classifier 🏷️)

"Every error deserves a proper funeral."

When to Activate

  • Writing new API endpoints or services.
  • Debugging error handling logic.
  • User mentions: "error handling", "exception", "try-catch", "error boundary".

Error Categories

CategoryExamplesStrategy
ValidationInvalid input, missing fieldReturn 422 + field-level errors
AuthenticationInvalid token, expired sessionReturn 401 + redirect to login
AuthorizationForbidden resourceReturn 403 + log attempt
Not FoundMissing recordReturn 404 + user-friendly message
Business LogicInsufficient balance, duplicateReturn 409/422 + business message
InfrastructureDB down, service timeoutReturn 503 + retry header + alert
UnknownUncaught exceptionReturn 500 + log full stack + alert

Rules

  • NEVER expose stack traces to end users.
  • ALWAYS log the full error internally.
  • User-facing messages must be human-readable, not technical.
  • Use error codes for machine-readable identification.
  • Implement error boundaries in frontend (React ErrorBoundary, Vue errorCaptured).

Cost: Low