variable / @typed/fx

Push.mapError

Transforms the output (Fx) error channel of a Push using the provided function.

Failures (Cause) are mapped via Cause.map, so only the typed failure (Fail) is transformed; defects and interrupts are preserved unchanged.

Mirrors Effect.mapError on the Fx side. Cardinality, value order, input callbacks, and output service requirements are unchanged.

Package version
2.0.0-beta.13
Category
Output failures
Since
1.0.0
Member of
Push

Import

import { Push } from "@typed/fx";

Access Push.mapError through the imported Push 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 mapError: {
    <E2, E3>(f: (e: E2) => E3): <A, E, R, B, R2>(push: Push<A, E, R, B, E2, R2>) => Push<A, E, R, B, E3, R2>;
    <A, E, R, B, E2, R2, E3>(push: Push<A, E, R, B, E2, R2>, f: (e: E2) => E3): Push<A, E, R, B, E3, R2>;
};

Why

Normalize an output failure type at the observation boundary without touching input errors or collapsing defects and interruption into typed failures.

Ownership and lifetime

The mapping is synchronous and resource-free. It runs when the output Cause is delivered and preserves the upstream subscription, Scope, interruption, and cleanup behavior.

Examples

import { Effect } from "effect"
import * as Fx from "@typed/fx/Fx"
import * as Push from "@typed/fx/Push"
import * as Sink from "@typed/fx/Sink"

const push = Push.make(Sink.make(() => Effect.void, (_: string) => Effect.void), Fx.fail("offline"))
const normalized = Push.mapError(push, (message) => ({ message }))

Other public imports

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

Source