effect-ts-errors
Installation
SKILL.md
Effect-TS Error Handling
Overview
Effect-TS provides a type-safe error channel (E in Effect<A, E, R>) that tracks potential failures. Use Tagged Errors for distinguishability and specialized combinators for handling or accumulating errors.
When to Use
- Defining custom error types for domain logic.
- Handling specific errors without catching everything.
- Validating multiple fields and collecting all failures.
When NOT to use:
- Simple
try/catchfor non-Effect code. - When error types don't need to be distinguished (use
Effect.fail(message)).
Core Pattern
Before (Generic Errors):
if (!user) throw new Error("Not found");