Package: effect
Module: Exit
Pattern matches on an Exit, handling both success and failure cases.
When to use
Use when you need exhaustive handling of both Exit success and failure
outcomes.
Details
Calls onSuccess with the value if the Exit is a Success, and calls
onFailure with the Cause if the Exit is a Failure.
Example (Matching on an Exit)
import { Exit } from "effect"
const success = Exit.succeed(42)
const result = Exit.match(success, {
onSuccess: (value) => `Got: ${value}`,
onFailure: () => "Failed"
})
console.log(result) // "Got: 42"
See
isSuccess and isFailure for simple boolean checksSignature
declare const match: { <A, E, X1, X2>(options: { readonly onSuccess: (a: NoInfer<A>) => X1; readonly onFailure: (cause: Cause.Cause<NoInfer<E>>) => X2; }): (self: Exit<A, E>) => X1 | X2; <A, E, X1, X2>(self: Exit<A, E>, options: { readonly onSuccess: (a: A) => X1; readonly onFailure: (cause: Cause.Cause<E>) => X2; }): X1 | X2; }
Since v2.0.0