Follow one execution
Recovers from any failure cause by running a fallback Fx.
catchCauseTick 0. Source: start.
Read this diagram
Follow each lane from left to right. Events stacked vertically share a tick; the green cursor marks the current time across every lane.
- A value
The text inside the pill is the emitted value. - Work starts
The raised chevron starts an inner run (^in the source). - The run returns
The vertical bar ends this lane’s run. - A cause is delivered
The exclamation mark belongs to this lane. - Work is interrupted
The cross marks cancellation of this run. - Current time
The line and diamond move together across all lanes. - Happening now
A highlighted event is at the current tick. - Still ahead
Muted, dashed values have not happened yet. - Time continues
The lane’s arrow is not a return marker. An empty stretch can be quiet work that is still running.
Illustrated ticks start at 0. At 1×, one illustrated tick takes one second; captions specify real durations when timing matters. A cause or interruption belongs to its lane, and other work may continue. Scroll horizontally to inspect the rest of a long timeline.
The handler runs once after the source reports a cause and its returned Fx continues in the same subscription. It receives the cause unchanged. Values emitted before failure are not replayed, and the fallback’s errors and services replace the recovered source error and join its requirements. Because interruption is catchable here, use this only when intentionally translating interruption rather than for ordinary typed recovery.
Import
import { Fx } from "@typed/fx";Access Fx.catchCause through the imported Fx export. Its declaration below describes the member.
This public exposure is a re-export. Its import path is supported; declaration documentation is shared with the other public exposures below.
Signatures
export declare const catchCause: {
<E, A2, E2, R2>(f: (cause: Cause.Cause<E>) => Fx<A2, E2, R2>): <A, R>(self: Fx<A, E, R>) => Fx<A | A2, E2, R | R2>;
<A, E, R, A2, E2, R2>(self: Fx<A, E, R>, f: (cause: Cause.Cause<E>) => Fx<A2, E2, R2>): Fx<A | A2, E2, R | R2>;
};Why
A full Cause retains typed failures, defects, interruption, and composed
causes. Handling that structure explicitly is necessary at boundaries that
must translate every termination mode rather than only expected errors.
Ownership and lifetime
The handler runs once after the source reports a cause and its returned Fx continues in the same subscription. It receives the cause unchanged. Values emitted before failure are not replayed, and the fallback’s errors and services replace the recovered source error and join its requirements. Because interruption is catchable here, use this only when intentionally translating interruption rather than for ordinary typed recovery.
Examples
import { Cause } from "effect"
import { catchCause } from "@typed/fx/Fx"
import { failCause, succeed } from "@typed/fx/Fx"
const reported = catchCause(failCause(Cause.die("boom")), (cause) =>
succeed(Cause.pretty(cause))
)Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.