<E>(self: Cause<E>): ReadonlySet<number>Collects the defined fiber IDs from all Interrupt reasons in the
cause into a ReadonlySet. Interrupt reasons without a fiberId are
ignored. Returns an empty set when the cause has no interrupting fiber IDs.
When to use
Use when you need interrupting fiber IDs as a set, with absence represented as an empty set.
Example (Collecting interruptors)
import { Cause } from "effect"
const cause = Cause.combine(
Cause.interrupt(1),
Cause.interrupt(2)
)
console.log(Cause.interruptors(cause)) // Set(2) { 1, 2 }export const const interruptors: <E>(
self: Cause<E>
) => ReadonlySet<number>
Collects the defined fiber IDs from all Interrupt reasons in the
cause into a ReadonlySet. Interrupt reasons without a fiberId are
ignored. Returns an empty set when the cause has no interrupting fiber IDs.
When to use
Use when you need interrupting fiber IDs as a set, with absence represented
as an empty set.
Example (Collecting interruptors)
import { Cause } from "effect"
const cause = Cause.combine(
Cause.interrupt(1),
Cause.interrupt(2)
)
console.log(Cause.interruptors(cause)) // Set(2) { 1, 2 }
interruptors: <function (type parameter) E in <E>(self: Cause<E>): ReadonlySet<number>E>(self: Cause<E>(parameter) self: {
reasons: ReadonlyArray<Reason<E>>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self: 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<function (type parameter) E in <E>(self: Cause<E>): ReadonlySet<number>E>) => interface ReadonlySet<T>ReadonlySet<number> = import effecteffect.const causeInterruptors: <E>(
self: Cause.Cause<E>
) => ReadonlySet<number>
causeInterruptors