effect-io-ai

Package: effect
Module: Cause

Cause.Cause

A structured representation of how an Effect failed.

When to use

Use to preserve the full structured failure information for an effect instead of collapsing it to a single error value.

Details

Access the individual failure entries through the reasons array, then narrow each entry with isFailReason, isDieReason, or isInterruptReason.

Cause implements Equal — two causes with the same reasons (by value) compare as equal.

Example (Creating and inspecting a cause)

import { Cause } from "effect"

const cause = Cause.fail("Something went wrong")
console.log(cause.reasons.length) // 1
console.log(Cause.isFailReason(cause.reasons[0])) // true

Signature

export interface Cause<out E> extends Pipeable, Inspectable, Equal {
  readonly [TypeId]: typeof TypeId
  readonly reasons: ReadonlyArray<Reason<E>>
}

Source

Since v2.0.0