<E>(cause: Cause.Cause<E>): Exit<never, E>Creates a failed Exit from a Cause.
When to use
Use when you already have a Cause<E> and want to wrap it in an Exit
for advanced error handling where you need full control over the Cause
structure.
Details
Returns a Failure<never, E>. If you only have an error value, use
fail instead.
Example (Creating a failed Exit from a Cause)
import { Cause, Exit } from "effect"
const cause = Cause.fail("Something went wrong")
const exit = Exit.failCause(cause)
console.log(Exit.isFailure(exit)) // trueexport const const failCause: <E>(
cause: Cause.Cause<E>
) => Exit<never, E>
Creates a failed Exit from a Cause.
When to use
Use when you already have a Cause<E> and want to wrap it in an Exit
for advanced error handling where you need full control over the Cause
structure.
Details
Returns a Failure<never, E>. If you only have an error value, use
fail
instead.
Example (Creating a failed Exit from a Cause)
import { Cause, Exit } from "effect"
const cause = Cause.fail("Something went wrong")
const exit = Exit.failCause(cause)
console.log(Exit.isFailure(exit)) // true
failCause: <function (type parameter) E in <E>(cause: Cause.Cause<E>): Exit<never, E>E>(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.type Cause.Cause = /*unresolved*/ anyCause<function (type parameter) E in <E>(cause: Cause.Cause<E>): Exit<never, E>E>) => 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<never, function (type parameter) E in <E>(cause: Cause.Cause<E>): Exit<never, E>E> = import corecore.const exitFailCause: <E>(
cause: Cause.Cause<E>
) => Exit.Exit<never, E>
exitFailCause