Hyperlinkv0.8.0-beta.28

Channel

Channel.failCauseSyncconsteffect/Channel.ts:1047
<E>(evaluate: LazyArg<Cause.Cause<E>>): Channel<never, E, never>

Constructs a channel that fails immediately with the specified lazily evaluated Cause.

Example (Failing with lazy causes)

import { Cause, Channel } from "effect"

// Create a channel that fails with a lazily computed cause
let attempts = 0
const failedChannel = Channel.failCauseSync(() => {
  attempts += 1
  return Cause.fail(`Runtime error after attempt ${attempts}`)
})

// Create a channel with die cause computation
const dieCauseChannel = Channel.failCauseSync(() => {
  const operation = "load-profile"
  return Cause.die(`Unexpected defect during ${operation}`)
})
constructors
export const failCauseSync = <E>(
  evaluate: LazyArg<Cause.Cause<E>>
): Channel<never, E, never> => fromPull(Effect.failCauseSync(evaluate))
Referenced by 1 symbols