function / @typed/async-data

getCause

Returns the complete Cause only when the current state is a Failure.

Package version
1.0.0-beta.13
Category
State extraction
Since
1.0.0

Import

import { getCause } from "@typed/async-data";

Signatures

export declare function getCause<A, E>(data: AsyncData<A, E>): Option.Option<Cause.Cause<E>>;

Why

The accessor keeps typed errors, defects, and interruption intact for callers that need full failure diagnostics.

Ownership and lifetime

This pure lookup acquires no resources and returns a reference to the persistent Cause.

Examples

import { failure, getCause } from "@typed/async-data"
import { Cause } from "effect"
const cause = getCause(failure(Cause.fail("offline")))

Source