Skip to main content

tryCatch()

tryCatch<E, A>(f, onRejected): TaskEither<E, A>

Creates a TaskEither from a Promise that may reject.


Type Parametersโ€‹

E: Eโ€‹

The error type.

A: Aโ€‹

The success type.


Parametersโ€‹

f: () => Promise<A>โ€‹

The async function to execute.

onRejected: (reason) => Eโ€‹

Function to transform rejection reason.


Returns: TaskEither<E, A>โ€‹

A TaskEither containing the result or error.


Sinceโ€‹

2.0.0