The union of tag strings that this handler covers
The Effect type returned by each handler
A WrapEffect that can be used in a pipe chain
Accepts a record mapping tag strings to handler functions. When the preceding
effect fails with a tagged error (created via failure), the handler
matching the error's __tag is invoked. If no handler matches, the error
propagates unchanged.
This enables type-safe, pattern-matched error recovery — each branch of the handler record addresses a specific failure type. The caught error types are removed from the resulting effect's error channel.
import { failure, fn, pipe, catchTags, succeed, run } from "mini-effect";
const NotFound = failure("NotFound");
const Unauthorized = failure("Unauthorized");
const result = await run(
pipe(
fn(() => { throw new NotFound(); }),
catchTags({
NotFound: () => succeed("fallback"),
Unauthorized: () => succeed("login"),
}),
),
);
// => "fallback"
Creates a WrapEffect that catches tagged errors by their
__tagproperty.