effect-io-ai

Package: effect
Module: Cause

Cause.Fail

A typed, expected error produced by Effect.fail.

When to use

Use when inspecting Cause reasons that represent expected failures from the typed error channel.

Details

The error property carries the typed value E. Use isFailReason to narrow a Reason to this type.

Example (Accessing the error)

import { Cause } from "effect"

const cause = Cause.fail("Something went wrong")
const reason = cause.reasons[0]
if (Cause.isFailReason(reason)) {
  console.log(reason.error) // "Something went wrong"
}

See

Signature

export interface Fail<out E> extends Cause.ReasonProto<"Fail"> {
  readonly error: E
}

Source

Since v2.0.0