-
Notifications
You must be signed in to change notification settings - Fork 0
Variable.tryCatch
GitHub Actions edited this page May 22, 2025
·
1 revision
resultar / tryCatch
consttryCatch: <T,E>(fn,errorFn?) =>Result<T,E> =Result.tryCatch
Defined in: result.ts:630
Creates a Result by running a function that might throw.
If the function throws, the error will be caught and returned as an Err.
If the function succeeds, the value will be wrapped in an Ok.
T
E
() => Exclude<T, Promise<unknown>>
The function to execute, which might throw an error
(e) => E
Optional function to transform the thrown error before wrapping in Err
Result<T, E>
A Result containing either the function's return value or the caught error