Aller au contenu principal

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