What problem does it solve?
This Skill provides comprehensive guidance on implementing robust and maintainable error handling. It helps developers choose the right strategy (exceptions vs. Result pattern), provide rich error context, and implement recovery mechanisms like retries and circuit breakers, leading to more resilient applications.
Core Features & Use Cases
- Exceptions vs. Result Pattern: Guides on when to use exceptions for unexpected errors and the Result pattern for expected business failures.
- Custom Exception Hierarchy: Defines domain-specific and infrastructure-specific custom error classes with rich context.
- Validation Strategies: Emphasizes input validation at system boundaries (e.g., with Zod) and domain validation within entities.
- Error Recovery: Implements retry logic, circuit breakers, and fallback values for transient failures and external service dependencies.
- Use Case: "Implement the Result pattern for a
findByEmail operation in my UserService to gracefully handle 'user not found' scenarios without throwing exceptions."
Quick Start
Refactor a function to use custom exceptions with rich context instead of generic Error objects.