<A, E>(self: Exit<A, E>): self is Failure<A, E>Checks whether a failed Exit contains interruptions (Interrupt reasons).
When to use
Use to check whether an Exit contains fiber interruption.
Details
Returns false for successful exits. Only checks for Interrupt reasons in
the Cause. A Cause with only Fail or Die reasons returns false.
Example (Checking for interruptions)
import { Exit } from "effect"
console.log(Exit.hasInterrupts(Exit.interrupt(1))) // true
console.log(Exit.hasInterrupts(Exit.fail("err"))) // false
console.log(Exit.hasInterrupts(Exit.succeed(42))) // falseexport const const hasInterrupts: <A, E>(
self: Exit<A, E>
) => self is Failure<A, E>
Checks whether a failed Exit contains interruptions (Interrupt reasons).
When to use
Use to check whether an Exit contains fiber interruption.
Details
Returns false for successful exits. Only checks for Interrupt reasons in
the Cause. A Cause with only Fail or Die reasons returns false.
Example (Checking for interruptions)
import { Exit } from "effect"
console.log(Exit.hasInterrupts(Exit.interrupt(1))) // true
console.log(Exit.hasInterrupts(Exit.fail("err"))) // false
console.log(Exit.hasInterrupts(Exit.succeed(42))) // false
hasInterrupts: <function (type parameter) A in <A, E>(self: Exit<A, E>): self is Failure<A, E>A, function (type parameter) E in <A, E>(self: Exit<A, E>): self is Failure<A, E>E>(self: Exit<A, E>self: type Exit<A, E = never> = Success<A, E> | Failure<A, E>Represents the result of an Effect computation.
When to use
Use when you need to synchronously inspect whether an Effect computation
succeeded or failed.
Details
An Exit<A, E> is either Success<A, E> containing a value of type A, or
Failure<A, E> containing a Cause<E> describing why the computation
failed.
Since Exit is also an Effect, you can yield it inside Effect.gen.
Example (Pattern matching on an Exit)
import { Exit } from "effect"
const success: Exit.Exit<number> = Exit.succeed(42)
const failure: Exit.Exit<number, string> = Exit.fail("error")
const result = Exit.match(success, {
onSuccess: (value) => `Got value: ${value}`,
onFailure: (cause) => `Got error: ${cause}`
})
Namespace containing helper types shared by Exit values.
When to use
Use to reference helper types that describe the shared structure of Exit
values.
Exit<function (type parameter) A in <A, E>(self: Exit<A, E>): self is Failure<A, E>A, function (type parameter) E in <A, E>(self: Exit<A, E>): self is Failure<A, E>E>) => self: Exit<A, E>self is 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<function (type parameter) A in <A, E>(self: Exit<A, E>): self is Failure<A, E>A, function (type parameter) E in <A, E>(self: Exit<A, E>): self is Failure<A, E>E> = import effecteffect.const exitHasInterrupts: <A, E>(
self: Exit.Exit<A, E>
) => self is Exit.Failure<A, E>
exitHasInterrupts