Type Parameters
- TT extends unknown
- CT extends unknown
- FT extends unknown
Parameters
- trycallbackfn: () => TT
Optionalcatchcallbackfn: (e: Error) => CTOptionalfinallycallbackfn: (v: undefined | TT | CT) => FT
Returns undefined | TT | CT | FT
The result of the finallycallbackfn function, unless it does not return a value, in which case it will return the result of the catchcallbackfn function, or if there was no error, the result of the trycallbackfn function.
Runs a callback function and catches any errors that occur.
If an error occurs, it will run the
catchcallbackfnfunction, and return the result of that function, unless thefinallycallbackfnfunction returns a value.It will then run the
finallycallbackfnfunction, whether an error occurred or not, and return the result of that function or if it does not return anything, the result of thecatchcallbackfnfunction, or if there was no error, the result of thetrycallbackfnfunction.