effect-io-ai

Package: effect
Module: Cause

Cause.Die

An untyped defect — typically a programming error or an uncaught exception.

When to use

Use when inspecting Cause reasons that represent defects instead of typed failures or interruptions.

Details

The defect property is unknown because defects are not part of the typed error channel. Use isDieReason to narrow a Reason to this type.

Example (Accessing the defect)

import { Cause } from "effect"

const cause = Cause.die("Unexpected")
const reason = cause.reasons[0]
if (Cause.isDieReason(reason)) {
  console.log(reason.defect) // "Unexpected"
}

See

Signature

export interface Die extends Cause.ReasonProto<"Die"> {
  readonly defect: unknown
}

Source

Since v2.0.0