Type Parameters
- TT extends unknown
- CT extends unknown
- FT extends unknown
Parameters
- trycallbackfn: () => TT
Optional
catchcallbackfn: (e: Error) => CTOptional
finallycallbackfn: (v: TT | CT) => FT
Returns 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
catchcallbackfn
function, and return the result of that function, unless thefinallycallbackfn
function returns a value.It will then run the
finallycallbackfn
function, whether an error occurred or not, and return the result of that function or if it does not return anything, the result of thecatchcallbackfn
function, or if there was no error, the result of thetrycallbackfn
function.