Type Parameters
-
R
-
T extends ((...args) => Promise<void | R>)
Parameters
-
func: T
-
Optional
onError: ((error) => void)
-
- (error): void
-
Returns void
Returns ((this, ...args) => Promise<void | R>)
A new function that wraps the original function with error handling.
-
- (this, ...args): Promise<void | R>
-
Parameters
-
this: unknown
-
Rest
...args: Parameters<T>
Returns Promise<void | R>
Wraps an asynchronous function, catches all sync and async errors and passes them to the onError callback instead of throwing. All promises are resolved. If there was an error, they are resolved with 'undefined'.