(self: unknown): self is Cause<unknown>Checks whether an arbitrary value is a Cause.
Example (Checking the runtime type)
import { Cause } from "effect"
console.log(Cause.isCause(Cause.fail("error"))) // true
console.log(Cause.isCause("not a cause")) // falseguards
Source effect/Cause.ts:971 lines
export const const isCause: (
self: unknown
) => self is Cause<unknown>
Checks whether an arbitrary value is a Cause.
Example (Checking the runtime type)
import { Cause } from "effect"
console.log(Cause.isCause(Cause.fail("error"))) // true
console.log(Cause.isCause("not a cause")) // false
isCause: (self: unknownself: unknown) => self: unknownself is interface Cause<out E>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
- Use
hasFails
/
hasDies
/
hasInterrupts
to test
for the presence of specific reason kinds without iterating.
- Use
findError
/
findDefect
to extract the first value
of a given kind.
- Use
combine
to merge two causes.
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
Companion namespace for the Cause interface.
Cause<unknown> = import corecore.const isCause: (
self: unknown
) => self is Cause.Cause<unknown>
isCauseReferenced by 2 symbols