effect-error-handling

Implement typed error handling for Effect v4 programs using Schema.TaggedErrorClass and catch combinators.

22|1|Updated Apr 14, 2026
One-click install
npx skills add https://github.com/mpsuesser/pi-effect-harness --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/pi-effect-harness/tree/main/harnesses/effect/skills/effect-error-handling
Command: npx skills add https://github.com/mpsuesser/pi-effect-harness --skill effect-error-handling-mpsuesser

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Effect programs frequently fail in ways that are either too vague (defects) or too messy (untyped error handling), making recovery inconsistent and unsafe across layers; this skill helps you design and implement typed, tag-based error channels in Effect v4 so callers can reliably match and recover.

Core Features & Use Cases

  • Typed error classes with schemas: Build domain errors using Schema.TaggedErrorClass so errors carry an explicit _tag and validated payload.
  • Correct v4 catching primitives: Use Effect.catchTag/catchTags, Effect.catchReason/catchReasons, Effect.unwrapReason, Effect.catchFilter, and Cause inspectors to handle failures precisely.
  • Defects vs error channel boundaries: Distinguish expected business failures (error channel) from programming errors (defects) and place conversions at adapter boundaries.
  • Cause model that matches v4 reality: Treat Cause as a flat array of reasons and use Cause.hasFails/hasDies/hasInterrupts and Cause.findErrorOption/findDefect/findInterrupt.
  • Exhaustive matching patterns: Prefer structured error handling with Match-ready patterns to avoid missing error variants.

Quick Start

Tell the AI: "Show me how to define a Schema.TaggedErrorClass for a tagged API failure, then update my Effect.gen code to catch only that tag and recover with a sensible fallback using the correct Effect v4 combinators."

Frequently Asked Questions about effect-error-handling

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

FAQPage Schema
How do I define typed errors in Effect v4 using Schema.TaggedErrorClass?

Typed errors in Effect v4 are defined using Schema.TaggedErrorClass to build domain errors carrying an explicit _tag and validated payload. This schema-validated structure enables precise matching and safe recovery across service layers.

What is the difference between defects and expected business failures in Effect error handling?

In Effect error handling, expected business failures flow through the error channel for reliable recovery, while defects represent programming errors. You place conversions between these boundaries at adapter layers to maintain safe error channels.

How do I catch specific tagged errors in Effect v4?

Catch specific tagged errors in Effect v4 using Effect.catchTag, catchTags, catchFilter, or catchReason combinators. These primitives let you match specific error tags or flat reasons precisely, enabling structured recovery with sensible fallbacks in Effect.gen code.

How does the Effect v4 Cause model work for inspecting failures?

The Effect v4 Cause model treats Cause as a flat array of reasons. You inspect failures using Cause.hasFails, hasDies, hasInterrupts, and findErrorOption, findDefect, or findInterrupt to precisely examine error channels and defect structures in service-layer code.

What's the best way to ensure exhaustive error matching in Effect programs?

Ensure exhaustive error matching in Effect programs by using Match-ready patterns with structured error handling. This approach prevents missing error variants by requiring all tagged error cases to be addressed, avoiding inconsistent and unsafe recovery across architectural layers.