Package: effect
Module: Effect
Runs the finalizer only when this effect fails and the Cause matches the
provided predicate.
Example (Running cleanup for selected failures)
import { Cause, Console, Effect } from "effect"
const task = Effect.fail("boom")
const program = Effect.onErrorIf(
task,
Cause.hasFails,
(cause) =>
Effect.gen(function*() {
yield* Console.log(`Cause: ${Cause.pretty(cause)}`)
})
)
Signature
declare const onErrorIf: { <E, XE, XR>(predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<void, XE, XR>): <A, R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>; <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>; }
Since v4.0.0