- fromThrowable<Fn extends ((...args: readonly any[]) => any), E>(fn: Fn, errorFn?: ((e: unknown) => E)): ((...args: Parameters<Fn>) => neverthrow.Result<ReturnType<Fn>, E>)
Type Parameters
- Fn extends ((...args: readonly any[]) => any)
- E
Parameters
- fn: Fn
Optional
errorFn: ((e: unknown) => E)
Wraps a function with a try catch, creating a new function with the same arguments but returning
Ok
if successful,Err
if the function throws