Skip to main content

tryCatch()

tryCatch<E, A>(f, onThrow): Either<E, A>

Creates an Either by executing a function that may throw.


Type Parametersโ€‹

E: Eโ€‹

The error type.

A: Aโ€‹

The success type.


Parametersโ€‹

f: () => Aโ€‹

The function to execute.

onThrow: (e) => Eโ€‹

Function to transform thrown errors.


Returns: Either<E, A>โ€‹

An Either containing the result or error.


Sinceโ€‹

2.0.0