Package: effect
Module: Exit
Transforms the typed error of a failed Exit using the given function.
When to use
Use to remap typed errors while preserving the Exit structure
Details
Successes pass through unchanged.
Allocates a new Exit if the error is transformed.
Gotchas
Only transforms typed errors (Fail reasons). If the Cause contains only defects or interruptions, the failure passes through unchanged.
Example (Mapping over an error)
import { Data, Exit } from "effect"
class ExitError extends Data.TaggedError("ExitError")<{ readonly input: string }> {}
const exit = Exit.fail("bad input")
const mapped = Exit.mapError(exit, (e) => new ExitError({ input: e }))
console.log(Exit.isFailure(mapped)) // true
See
map to transform the success valuemapBoth to transform both success and errorSignature
declare const mapError: { <E, E2>(f: (a: NoInfer<E>) => E2): <A>(self: Exit<A, E>) => Exit<A, E2>; <A, E, E2>(self: Exit<A, E>, f: (a: NoInfer<E>) => E2): Exit<A, E2>; }
Since v2.0.0