<A, E>(results: ReadonlyArray<NodeResult<A, E>>): ReadonlyArray<{
readonly node: string
readonly cause: Cause.Cause<E>
}>The nodes whose gather failed, with their cause.
export const const combineFailures: <A, E>(
results: ReadonlyArray<NodeResult<A, E>>
) => ReadonlyArray<{
readonly node: string
readonly cause: Cause.Cause<E>
}>
The nodes whose gather failed, with their cause.
combineFailures = <function (type parameter) A in <A, E>(results: ReadonlyArray<NodeResult<A, E>>): ReadonlyArray<{
readonly node: string;
readonly cause: Cause.Cause<E>;
}>
A, function (type parameter) E in <A, E>(results: ReadonlyArray<NodeResult<A, E>>): ReadonlyArray<{
readonly node: string;
readonly cause: Cause.Cause<E>;
}>
E>(
results: ReadonlyArray<NodeResult<A, E>>results: interface ReadonlyArray<T>ReadonlyArray<interface NodeResult<A, E = never>One node's outcome for a gathered query field — node-attributed success/failure.
NodeResult<function (type parameter) A in <A, E>(results: ReadonlyArray<NodeResult<A, E>>): ReadonlyArray<{
readonly node: string;
readonly cause: Cause.Cause<E>;
}>
A, function (type parameter) E in <A, E>(results: ReadonlyArray<NodeResult<A, E>>): ReadonlyArray<{
readonly node: string;
readonly cause: Cause.Cause<E>;
}>
E>>,
): interface ReadonlyArray<T>ReadonlyArray<{ readonly node: stringnode: string; readonly cause: Cause.Cause<E>(property) 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
isInterruptReason
.
- 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 <A, E>(results: ReadonlyArray<NodeResult<A, E>>): ReadonlyArray<{
readonly node: string;
readonly cause: Cause.Cause<E>;
}>
E> }> =>
results: ReadonlyArray<NodeResult<A, E>>results.ReadonlyArray<NodeResult<A, E>>.flatMap<{
node: string;
cause: Cause.Cause<E>;
}, undefined>(callback: (this: undefined, value: NodeResult<A, E>, index: number, array: NodeResult<A, E>[]) => {
node: string;
cause: Cause.Cause<E>;
} | readonly {
node: string;
cause: Cause.Cause<E>;
}[], thisArg?: undefined): {
node: string;
cause: Cause.Cause<E>;
}[]
Calls a defined callback function on each element of an array. Then, flattens the result into
a new array.
This is identical to a map followed by flat with depth 1.
flatMap((r: NodeResult<A, E>(parameter) r: {
node: string;
exit: Exit.Exit<A, E>;
}
r) => (import ExitExit.const isFailure: <A, E>(
self: Exit.Exit<A, E>
) => self is Exit.Failure<A, E>
Checks whether an Exit is a Failure.
When to use
Use as a type guard to narrow Exit<A, E> to Failure<A, E> and access the
cause property.
Example (Narrowing to failure)
import { Exit } from "effect"
const exit = Exit.fail("error")
if (Exit.isFailure(exit)) {
console.log(exit.cause)
}
isFailure(r: NodeResult<A, E>(parameter) r: {
node: string;
exit: Exit.Exit<A, E>;
}
r.NodeResult<A, E>.exit: Exit.Exit<A, E>exit) ? [{ node: stringnode: r: NodeResult<A, E>(parameter) r: {
node: string;
exit: Exit.Exit<A, E>;
}
r.NodeResult<A, E>.node: stringnode, cause: Cause.Cause<E>(property) 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: r: NodeResult<A, E>(parameter) r: {
node: string;
exit: Exit.Exit<A, E>;
}
r.NodeResult<A, E>.exit: Exit.Failure<A, E>(property) NodeResult<A, E>.exit: {
_tag: "Failure";
cause: Cause.Cause<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;
}
exit.Failure<A, E>.cause: Cause.Cause<E>(property) Failure<A, E>.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 }] : []));