What problem does it solve?
This Skill enforces a consistent, safe approach to mapping internal exceptions into structured API error responses, preventing leaked stack traces and inconsistent status codes.
Core Features & Use Cases
- Typed Error Taxonomy: A hierarchical AppError base with Domain, Infra, and Auth subclasses mapped to canonical HTTP status codes.
- Centralized Middleware: A single error-handler middleware that distinguishes operational vs programming errors, logs with traceId, and returns consistent JSON responses.
- Layered Patterns & Rules: Best-practice guidance for controllers, services, and repositories including when to throw typed errors and how to wrap infrastructure failures.
- Use Case: In a microservice API, use the taxonomy to convert validation failures to 422, not-found to 404, DB faults to DatabaseError with 503, and ensure clients never receive stack traces.
Quick Start
Implement the AppError hierarchy, throw typed errors in services and repositories, and register the centralized error-handler middleware so all routes forward exceptions and clients receive consistent JSON error responses.