backend-error-handling
Installation
SKILL.md
Backend Error Handling
Use this skill when
- Defining a uniform error response contract
- Mapping exceptions to HTTP responses
- Logging errors with context while keeping responses safe
Do not use this skill when
- General exception design patterns (use error-handling-patterns)
- Frontend error UX
Instructions
- Define a global error contract: code, message, detail, traceId.
- Centralize error-to-response mapping (error middleware/advice/filters).
- Log stack traces server-side; never return them or internals to clients.
- Use consistent status codes: 400 validation, 401/403 auth, 404, 409 conflict, 422 state.
- Attach a request trace ID to every error response and log.
- Handle async/background errors explicitly.
- Fail fast at boundaries; don’t swallow unknown errors.