Package: effect
Module: Cause
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
die for constructing a cause with a single Die reasonisDieReason for narrowing a Reason to DieSignature
export interface Die extends Cause.ReasonProto<"Die"> {
readonly defect: unknown
}
Since v2.0.0