Hyperlinkv0.8.0-beta.28

Effect

Effect.failCauseconsteffect/Effect.ts:1539
<E>(cause: Cause.Cause<E>): Effect<never, E>

Creates an Effect that represents a failure with a specific Cause.

When to use

Use when you already have a full Cause and need to preserve defects, interruptions, annotations, or combined failures in the effect's failure channel.

Details

This function allows you to create effects that fail with complex error structures, including multiple errors, defects, interruptions, and more.

Example (Failing with a full Cause)

import { Cause, Effect } from "effect"

const program = Effect.failCause(
  Cause.fail("Network error")
)

Effect.runPromiseExit(program).then(console.log)
// Output: { _id: 'Exit', _tag: 'Failure', cause: ... }
constructors
Source effect/Effect.ts:15391 lines
export const failCause: <E>(cause: Cause.Cause<E>) => Effect<never, E> = internal.failCause
Referenced by 22 symbols