Failure<A, E>A failed Exit containing a Cause.
When to use
Use when working with the failed branch of an Exit after narrowing with
isFailure. Access the cause via the cause property after
narrowing.
Details
The Cause<E> may contain typed errors, defects, or interruptions.
Example (Accessing the failure cause)
import { Exit } from "effect"
const failure = Exit.fail("something went wrong")
if (Exit.isFailure(failure)) {
console.log(failure._tag) // "Failure"
console.log(failure.cause) // Cause representing the error
}export interface interface Failure<out A, out E>A failed Exit containing a Cause.
When to use
Use when working with the failed branch of an Exit after narrowing with
isFailure
. Access the cause via the cause property after
narrowing.
Details
The Cause<E> may contain typed errors, defects, or interruptions.
Example (Accessing the failure cause)
import { Exit } from "effect"
const failure = Exit.fail("something went wrong")
if (Exit.isFailure(failure)) {
console.log(failure._tag) // "Failure"
console.log(failure.cause) // Cause representing the error
}
Failure<out function (type parameter) A in Failure<out A, out E>A, out function (type parameter) E in Failure<out A, out E>E> extends Exit.interface Exit<A, E = never>.Proto<out A, out E = never>Base interface shared by both Success and Failure.
When to use
Use to describe the common protocol implemented by every Exit value.
Details
Every Exit is also an Effect, so you can yield it in Effect.gen.
Proto<function (type parameter) A in Failure<out A, out E>A, function (type parameter) E in Failure<out A, out E>E> {
readonly Failure<out A, out E>._tag: "Failure"_tag: "Failure"
readonly Failure<out A, out E>.cause: Cause.Cause<E>(property) Failure<out A, out 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: import CauseCause.type Cause.Cause = /*unresolved*/ anyCause<function (type parameter) E in Failure<out A, out E>E>
}