effect-io-ai

Package: effect
Module: Exit

Exit.match

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

Signature

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; }

Source

Since v2.0.0