<E>(e: E): Exit<never, E>Creates a failed Exit from a typed error value.
When to use
Use when you need to represent an expected typed failure as an Exit.
Details
The error is wrapped in a Cause.Fail internally.
Returns a Failure<never, E>.
Example (Creating a failed Exit)
import { Exit } from "effect"
const exit = Exit.fail("Something went wrong")
console.log(Exit.isFailure(exit)) // trueexport const const fail: <E>(e: E) => Exit<never, E>Creates a failed Exit from a typed error value.
When to use
Use when you need to represent an expected typed failure as an Exit.
Details
The error is wrapped in a Cause.Fail internally.
Returns a Failure<never, E>.
Example (Creating a failed Exit)
import { Exit } from "effect"
const exit = Exit.fail("Something went wrong")
console.log(Exit.isFailure(exit)) // true
fail: <function (type parameter) E in <E>(e: E): Exit<never, E>E>(e: Ee: function (type parameter) E in <E>(e: 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>(e: E): Exit<never, E>E> = import corecore.const exitFail: <E>(
e: E
) => Exit.Exit<never, E>
exitFail