Hyperlinkv0.8.0-beta.28

Stream

Stream.failSyncconsteffect/Stream.ts:951
<E>(evaluate: LazyArg<E>): Stream<never, E>

Terminates with the specified lazily evaluated error.

Example (Failing a stream lazily)

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

const stream = Stream.failSync(() => "Uh oh!")

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: 'Uh oh!' } }
constructors
Source effect/Stream.ts:9511 lines
export const failSync = <E>(evaluate: LazyArg<E>): Stream<never, E> => fromChannel(Channel.failSync(evaluate))