effect-io-ai

Package: effect
Module: Channel

Channel.failCause

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)

Signature

declare const failCause: <E>(cause: Cause.Cause<E>) => Channel<never, E, never>

Source

Since v2.0.0