variable / @typed/async-data

mapError

Maps typed failures inside the base Cause while preserving defects, interruption, progress, and optimistic history.

Package version
1.0.0-beta.13
Category
Failure transformations
Since
1.0.0

Import

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

Signatures

export declare const mapError: {
    <A, E, E2>(f: (e: E) => E2): (data: AsyncData<A, E>) => AsyncData<A, E2>;
    <A, E, E2>(data: AsyncData<A, E>, f: (e: E) => E2): AsyncData<A, E2>;
};

Why

Error adaptation should use Effect Cause semantics instead of flattening the failure channel. Cyclic history throws TypeError.

Ownership and lifetime

This pure transformation acquires no resources and returns new plain wrappers.

Examples

import { failure, mapError } from "@typed/async-data"
import { Cause } from "effect"
const state = mapError(failure(Cause.fail(404)), String)

Source