effect-io-ai

Package: effect
Module: Effect

Effect.failCauseSync

Creates an Effect that represents a failure with a Cause computed lazily.

When to use

Use to defer computing a full Cause until the effect is run.

Details

The cause-producing function is evaluated each time the effect is executed.

Example (Lazily creating a Cause)

import { Cause, Effect } from "effect"

const program = Effect.failCauseSync(() =>
  Cause.fail("Error computed at runtime")
)

Effect.runPromiseExit(program).then(console.log)
// Output: { _id: 'Exit', _tag: 'Failure', cause: ... }

Signature

declare const failCauseSync: <E>(evaluate: LazyArg<Cause.Cause<E>>) => Effect<never, E>

Source

Since v2.0.0