variable / @typed/router

catchTag

Handles selected tagged failures and preserves unmatched variants.

Package version
1.0.0-beta.13
Category
Route recovery
Since
1.0.0

Import

import { catchTag } from "@typed/router";

Signatures

export declare const catchTag: {
    <I extends Fx.Fx.Any | Matcher.Any, const K extends Tags<InputError<I>> | Arr.NonEmptyReadonlyArray<Tags<InputError<I>>>, B, E2, R2>(k: K, f: (e: ExtractTag<NoInfer<InputError<I>>, K extends Arr.NonEmptyReadonlyArray<string> ? K[number] : K>) => Fx.Fx<B, E2, R2>): (input: I) => Fx.Fx<InputSucces<I> | B, E2 | ExcludeTag<InputError<I>, K extends Arr.NonEmptyReadonlyArray<string> ? K[number] : K>, InputServices<I> | R2 | Router | Scope.Scope>;
    <I extends Fx.Fx.Any | Matcher.Any, const K extends Tags<InputError<I>> | Arr.NonEmptyReadonlyArray<Tags<InputError<I>>>, B, E2, R2>(input: I, k: K, f: (e: ExtractTag<InputError<I>, K extends Arr.NonEmptyReadonlyArray<string> ? K[number] : K>) => Fx.Fx<B, E2, R2>): Fx.Fx<InputSucces<I> | B, E2 | ExcludeTag<InputError<I>, K extends Arr.NonEmptyReadonlyArray<string> ? K[number] : K>, InputServices<I> | R2 | Router | Scope.Scope>;
};

Why

Recovery narrows the error union instead of erasing it.

Ownership and lifetime

Calling the combinator constructs an Fx. A matching fallback runs in the consumer Scope; unmatched causes are forwarded unchanged.

Call signatures

Creates a data-first or data-last recovery Fx for selected error tags.

Call signatures: Why

Matching tags are removed from the resulting error union while unmatched tags and complete non-failure causes remain visible.

Call signatures: Ownership and lifetime

Calling this signature only constructs an Fx. A matching fallback is subscribed in the consumer Scope; unmatched causes reuse the original cause without acquiring fallback work.

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source