function / @typed/async-data

getError

Returns the first typed failure found in a Failure Cause.

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

Import

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

Signatures

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

Why

This convenience accessor intentionally excludes defects and interruption; use getCause when those distinctions matter.

Ownership and lifetime

This pure lookup acquires no resources and does not retain the state.

Examples

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

Source