<E>(cause: Cause.Cause<E>): booleanChecks whether a Cause contains any done errors.
When to use
Use when you need to test whether a pull failure cause represents normal completion and only need a boolean result.
export const const isDoneCause: <E>(
cause: Cause.Cause<E>
) => boolean
Checks whether a Cause contains any done errors.
When to use
Use when you need to test whether a pull failure cause represents normal
completion and only need a boolean result.
isDoneCause = <function (type parameter) E in <E>(cause: Cause.Cause<E>): booleanE>(cause: Cause.Cause<E>(parameter) cause: {
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;
}
cause: import CauseCause.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>(cause: Cause.Cause<E>): booleanE>): boolean => cause: Cause.Cause<E>(parameter) cause: {
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;
}
cause.Cause<E>.reasons: ReadonlyArray<Reason<E>>reasons.ReadonlyArray<Reason<E>>.some(predicate: (value: Cause.Reason<E>, index: number, array: readonly Cause.Reason<E>[]) => unknown, thisArg?: any): booleanDetermines whether the specified callback function returns true for any element of an array.
some(const isDoneFailure: <E>(
failure: Cause.Reason<E>
) => failure is Cause.Fail<E & Cause.Done<any>>
Checks whether a Cause.Reason is a Fail reason whose error is a
Cause.Done signal.
When to use
Use when you need to identify done completion reasons while traversing
cause.reasons, before handling ordinary failures.
isDoneFailure)