Skip to content

Function: tryCatchAsync()

ts
function tryCatchAsync<T, E>(fn, errorHandler): Promise<Result<T, E>>;

Defined in: result.ts:130

Wraps an async function in try/catch, returning a Promise of a Result. If the function throws or rejects, the error handler is called to produce the error value.

Type Parameters

Type ParameterDefault type
T-
EError

Parameters

ParameterType
fn() => Promise<T>
errorHandler(error) => E

Returns

Promise<Result<T, E>>