Skip to content

@morph-mapper/source


@morph-mapper/source / safeAsync

Function: safeAsync() ​

safeAsync<T>(fn): Promise<Result<T, Error>>

Defined in: queries.ts:9

Allows a function to be called safely and returns a Result instead of throwing an error.

Type Parameters ​

T ​

T

Parameters ​

fn ​

() => Promise<T>

Async function which throws an error when called.

Returns ​

Promise<Result<T, Error>>

A Result containing either the resolved value or the error that was thrown.