-
Notifications
You must be signed in to change notification settings - Fork 0
Function.tryCatch
GitHub Actions edited this page Mar 5, 2025
·
4 revisions
resultar / tryCatch
tryCatch<
T,E>(fn,errorFn?):Result<T,E>
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