What problem does it solve?
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.
Core Features & Use Cases
- Establish error taxonomy mapping to HTTP status codes and provide a stable string code for programmatic matching.
- Implement a base AppError class with code, message, statusCode, category, details, and cause, plus domain-specific subclasses (ValidationError, NotFoundError, AuthenticationError, AuthorizationError, ConflictError, RateLimitError, InternalError).
- Centralize error propagation with a single middleware/handler that converts errors to consistent HTTP responses, logs full causal chains, and includes a requestId for tracing.
- Enforce user-facing vs internal error separation, ensuring safe messages and stable codes in responses while logging full context internally.
- Include a documented error response schema and an error code registry for cross-service interoperability.
- Add structured logging fields such as code, message, category, correlationId, path, method, and stack.
Quick Start
Create a new error-handling skill by implementing the base AppError, several domain errors, and a centralized middleware, then integrate it with your API routes and logging.