Skip to content

Function.fromThrowableAsync

GitHub Actions edited this page Oct 23, 2024 · 27 revisions

resultar / fromThrowableAsync

Function: fromThrowableAsync()

fromThrowableAsync<A, T, E>(fn, errorFn?): (...args) => ResultAsync<T, E>

Wraps a async function with a try catch, creating a new function with the same arguments but returning Ok if successful, Err if the function throws

Type Parameters

A extends readonly any[]

T

E

Parameters

fn

function to wrap with ok on success or err on failure

errorFn?

when an error is thrown, this will wrap the error result if provided

Returns

Function

a new function that returns a ResultAsync

Parameters

• ...args: A

Returns

ResultAsync<T, E>

Defined in

result-async.ts:391

Clone this wiki locally