effect-error-handling

Implements typed error handling in Effect v4 using Schema.TaggedError, catch combinators, and Cause inspection.

3|Updated Apr 1, 2026
One-click install
npx skills add https://github.com/mpsuesser/opencode-effect-enforcer --skill effect-error-handling-mpsuesser
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: effect-error-handling
Source: https://github.com/mpsuesser/opencode-effect-enforcer/tree/main/skills/effect-error-handling
Command: npx skills add https://github.com/mpsuesser/opencode-effect-enforcer --skill effect-error-handling-mpsuesser

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Effect v4 renamed and restructured its error handling APIs, so agents and developers frequently write outdated v3 code like catchAll or recursive Cause trees. This Skill provides authoritative v4 guidance for modeling typed errors, catching failures by tag or reason, and distinguishing expected errors from defects. ## Core Features & Use Cases - Typed Error Modeling: Create domain errors with Schema.TaggedError, Schema.Error, or Data.TaggedError, including reason unions, HTTP status annotations, and cause wrapping conventions. - v4 Catch Combinators: Use catchTag, catchTags, catch, catchReason, catchReasons, catchFilter, catchEager, and unwrapReason with correct v4 semantics and optional orElse fallbacks. - Cause Inspection: Work with the flattened v4 Cause structure using findError, hasFails, isFailReason, and pretty rendering. - Use Case: When migrating an Effect v3 service to v4, use this Skill to replace catchAll with catch, convert Schema.TaggedErrorClass to Schema.TaggedError, and model nested failure reasons so callers can recover with catchReason. ## Quick Start Use the effect-error-handling skill to refactor this Effect service to use Schema.TaggedError and catchTag with proper v4 error channel types.

Frequently Asked Questions about effect-error-handling

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create typed errors in Effect v4?▼

Use Schema.TaggedError to define error classes with a _tag discriminator and schema-validated fields. For module-internal errors without serialization needs, Data.TaggedError is a lighter alternative, and Schema.Error suits custom discriminator fields.

What replaced Effect.catchAll in Effect v4?▼

Effect.catchAll was renamed to Effect.catch in v4. Related renames include catchAllCause to catchCause, catchAllDefect to catchDefect, and catchSome to catchFilter, which uses the Filter module instead of Option.

How do I handle multiple error types with catchTag in Effect v4?▼

In v4, catchTag accepts an array of tags to handle multiple error types with one handler, and catchTags takes an object mapping tags to handlers. Both support an optional trailing orElse parameter for unmatched errors.

When should I use defects instead of the error channel in Effect?▼

Use defects via Effect.die for programming errors, invariant violations, and unrecoverable adapter-internal failures. Reserve the typed error channel for caller-actionable business failures that the next layer can recover from.

How does the Cause structure differ between Effect v3 and v4?▼

Effect v4 flattens Cause into an object with a reasons array containing Fail, Die, and Interrupt variants, replacing v3's recursive tree. Use Cause.findError, hasFails, and isFailReason instead of the old failureOption and isFailType APIs.

What are catchReason and unwrapReason in Effect v4?▼

catchReason catches a specific reason variant nested inside a tagged error's reason field without removing the parent error. unwrapReason promotes the reason union into the error channel so individual reasons can be handled with catchTags.