Skip to content

Function.safeExecuteAsync

github-actions[bot] edited this page Aug 27, 2026 · 27 revisions

umt / safeExecuteAsync

Function: safeExecuteAsync()

safeExecuteAsync<V, E>(callback): Promise<Result<V, E>>

Defined in: Error/safeExecuteAsync.ts:18

Safely executes an async callback and returns a Result type Catches any errors and wraps them in a Result type

Type Parameters

V

V

The type of the success value

E

E = Error

The type of the error (defaults to Error)

Parameters

callback

() => V | Promise<V>

The async (or sync) function to execute safely

Returns

Promise<Result<V, E>>

A Promise of a Result containing either the value or the error

Example

await safeExecuteAsync(async () => 42);
// { type: "success", value: 42 }

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally