Skip to main content
variable attempt
import { attempt } from "https://deno.land/x/30_seconds_of_typescript@v1.0.1/util.ts";

Attempts to invoke a function with the provided arguments, returning either the result or the caught error object.

Use a try... catch block to return either the result of the function or an appropriate error.

type

(fn: (...args: any[]) => any, ...args: any[]) => unknown