Package: effect
Module: Effect
Runs an effect and returns a Promise that resolves to an Exit, which
represents the outcome (success or failure) of the effect.
When to use
Use when you need to determine if an effect succeeded
or failed, including any defects, and you want to work with a Promise.
Details
The Exit type represents the result of the effect. Successful effects are
wrapped in Success, and failed effects are wrapped in Failure with a
Cause.
Example (Observing promise results as Exit)
import { Effect } from "effect"
// Execute a successful effect and get the Exit result as a Promise
Effect.runPromiseExit(Effect.succeed(1)).then(console.log)
// Output:
// {
// _id: "Exit",
// _tag: "Success",
// value: 1
// }
// Execute a failing effect and get the Exit result as a Promise
Effect.runPromiseExit(Effect.fail("my error")).then(console.log)
// Output:
// {
// _id: "Exit",
// _tag: "Failure",
// cause: {
// _id: "Cause",
// _tag: "Fail",
// failure: "my error"
// }
// }
See
runPromise for a version that rejects on failure.Signature
declare const runPromiseExit: <A, E>(effect: Effect<A, E>, options?: RunOptions | undefined) => Promise<Exit.Exit<A, E>>
Since v2.0.0