- fromThrowable<Fn, E>(fn, errorFn?): ((...args) => Result<ReturnType<Fn>, E>)
Type Parameters
- Fn extends ((...args) => any)
- E
Parameters
- fn: Fn
Optional
errorFn: ((e) => E)
Returns ((...args) => Result<ReturnType<Fn>, E>)
- (...args): Result<ReturnType<Fn>, E>
Parameters
Rest
...args: Parameters<Fn>
Returns Result<ReturnType<Fn>, 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