(self: unknown): self is Reason<unknown>Checks whether an arbitrary value is a Reason (Fail, Die, or Interrupt).
Example (Checking the runtime type)
import { Cause } from "effect"
const reason = Cause.fail("error").reasons[0]
console.log(Cause.isReason(reason)) // true
console.log(Cause.isReason("not a reason")) // falseguards
Source effect/Cause.ts:1151 lines
export const const isReason: (
self: unknown
) => self is Reason<unknown>
Checks whether an arbitrary value is a Reason (Fail, Die, or Interrupt).
Example (Checking the runtime type)
import { Cause } from "effect"
const reason = Cause.fail("error").reasons[0]
console.log(Cause.isReason(reason)) // true
console.log(Cause.isReason("not a reason")) // false
isReason: (self: unknownself: unknown) => self: unknownself is type Reason<E> = Fail<E> | Die | InterruptA single entry inside a Cause's reasons array.
Details
Narrow to a concrete type with
isFailReason
,
isDieReason
,
or
isInterruptReason
.
Fail<E> — typed error, access via .error
Die — untyped defect, access via .defect
Interrupt — fiber interruption, access via .fiberId
Every reason carries an annotations map and an annotate method for
attaching tracing metadata.
Example (Narrowing a reason)
import { Cause } from "effect"
const reason = Cause.fail("error").reasons[0]
if (Cause.isFailReason(reason)) {
console.log(reason.error) // "error"
}
Companion namespace for the Reason type.
Reason<unknown> = import corecore.const isCauseReason: (
self: unknown
) => self is Cause.Reason<unknown>
isCauseReasonReferenced by 2 symbols