Skip to content

Variable.fromThrowableAsync

GitHub Actions edited this page May 22, 2025 · 1 revision

resultar / fromThrowableAsync

Variable: fromThrowableAsync()

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

Defined in: result-async.ts:477

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

A extends readonly any[]

T

T

E

E

Parameters

fn

(...args) => Promise<T>

function to wrap with ok on success or err on failure

errorFn?

(err) => E

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

Returns

a new function that returns a ResultAsync

(...args): ResultAsync<T, E>

Parameters

args

...A

Returns

ResultAsync<T, E>

Clone this wiki locally