effect-io-ai

Package: effect
Module: Stream

Stream.failCauseSync

The stream that always fails with the specified lazily evaluated Cause.

Example (Failing with a lazy cause)

import { Cause, Console, Effect, Stream } from "effect"

const stream = Stream.failCauseSync(() =>
  Cause.fail("Connection timeout after retries")
)

const program = Effect.gen(function*() {
  const exit = yield* Stream.runCollect(stream).pipe(Effect.exit)
  yield* Console.log(exit)
})

Effect.runPromise(program)
// Output:
// { _id: 'Exit', _tag: 'Failure', cause: { _id: 'Cause', _tag: 'Fail', failure: 'Connection timeout after retries' } }

Signature

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

Source

Since v2.0.0