Hyperlinkv0.8.0-beta.28

Channel

Channel.failCauseconsteffect/Channel.ts:1019
<E>(cause: Cause.Cause<E>): Channel<never, E, never>

Constructs a channel that fails immediately with the specified Cause.

When to use

Use when the channel failure must preserve a full Cause, such as defects, interruptions, or combined failures.

Example (Failing with causes)

import { Cause, Channel } from "effect"

// Create a channel that fails with a simple cause
const simpleCause = Cause.fail("Simple error")
const failedChannel = Channel.failCause(simpleCause)

// Create a channel with a die cause
const dieCause = Cause.die(new Error("System error"))
const dieFailure = Channel.failCause(dieCause)

// Create a channel with a simple fail cause
const failCause = Cause.fail("Simple error")
const simpleFail = Channel.failCause(failCause)
constructors
export const failCause = <E>(cause: Cause.Cause<E>): Channel<never, E, never> => fromPull(Effect.failCause(cause))
Referenced by 4 symbols