Skip to content

Function: tryCatch()

ts
function tryCatch<T, E>(fn, errorHandler): Result<T, E>;

Defined in: result.ts:115

Wraps a synchronous function in try/catch, returning a Result. If the function throws, the error handler is called to produce the error value.

Type Parameters

Type ParameterDefault type
T-
EError

Parameters

ParameterType
fn() => T
errorHandler(error) => E

Returns

Result<T, E>