<A, E>(self: Exit<A, E>): Option<E>Returns the first typed error from a failed Exit as an Option.
When to use
Use when you need the first typed error from an Exit as an Option,
ignoring successes and non-typed failures.
Details
Returns Option.some(error) if the Cause contains a Fail reason. Successes,
defect-only failures, and interrupt-only failures return Option.none().
Gotchas
Only finds the first Fail reason. If the Cause has multiple typed errors, the rest are ignored.
Example (Getting the first error)
import { Exit } from "effect"
console.log(Exit.findErrorOption(Exit.fail("err"))) // { _tag: "Some", value: "err" }
console.log(Exit.findErrorOption(Exit.die(new Error("bug")))) // { _tag: "None" }
console.log(Exit.findErrorOption(Exit.succeed(42))) // { _tag: "None" }export const const findErrorOption: <A, E>(
self: Exit<A, E>
) => Option<E>
Returns the first typed error from a failed Exit as an Option.
When to use
Use when you need the first typed error from an Exit as an Option,
ignoring successes and non-typed failures.
Details
Returns Option.some(error) if the Cause contains a Fail reason. Successes,
defect-only failures, and interrupt-only failures return Option.none().
Gotchas
Only finds the first Fail reason. If the Cause has multiple typed errors,
the rest are ignored.
Example (Getting the first error)
import { Exit } from "effect"
console.log(Exit.findErrorOption(Exit.fail("err"))) // { _tag: "Some", value: "err" }
console.log(Exit.findErrorOption(Exit.die(new Error("bug")))) // { _tag: "None" }
console.log(Exit.findErrorOption(Exit.succeed(42))) // { _tag: "None" }
findErrorOption: <function (type parameter) A in <A, E>(self: Exit<A, E>): Option<E>A, function (type parameter) E in <A, E>(self: Exit<A, E>): Option<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>): Option<E>A, function (type parameter) E in <A, E>(self: Exit<A, E>): Option<E>E>) => type Option<A> = None<A> | Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<function (type parameter) E in <A, E>(self: Exit<A, E>): Option<E>E> = import effecteffect.const exitFindErrorOption: <A, E>(
self: Exit.Exit<A, E>
) => Option.Option<E>
exitFindErrorOption