effect-io-ai

Package: effect
Module: Micro

Micro.try

The Micro equivalent of a try / catch block, which allows you to map thrown errors to a specific error type.

Example

import { Micro } from "effect"

Micro.try({
  try: () => { throw new Error("boom") },
  catch: (cause) => new Error("caught", { cause })
})

Signature

declare const try: <A, E>(options: { try: LazyArg<A>; catch: (error: unknown) => E; }) => Micro<A, E>

Source

Since v3.4.0