What problem does it solve?
Simplifies error handling and propagation in TypeScript backend/domain logic, ensuring predictable outcomes with the Result<T, E> type.
Core Features & Use Cases
- Error Discipline: Encapsulates business logic within
Result<T, E> for reliable error handling, avoiding exceptions and propagation at the transport boundary.
- Domain Layer: Framework-pure domain/services logic returns
Result, not exceptions, allowing for consistent failure handling.
- Transport Boundary: Translates
Result.error into a transport exception once at the boundary.
- Error Type Management: Discriminated union error types are clearly defined, with new variants affecting multiple components for consistency.
- Use Case: When implementing a backend service, this skill helps enforce a single point of error transformation at the transport layer, preventing errors from propagating deeper into the codebase.
Quick Start
Integrate 'result-pattern' into your TypeScript domain logic by defining Result types and using the 'ok' and 'err' functions to handle successful and failed outcomes, respectively.