UNPKG

764 BTypeScriptView Raw
1/**
2 * Wrap a callback function with error handling.
3 * If an error is thrown, it will be passed to the `onError` callback and re-thrown.
4 *
5 * If the return value of the function is a promise, it will be handled with `maybeHandlePromiseRejection`.
6 *
7 * If an `onFinally` callback is provided, this will be called when the callback has finished
8 * - so if it returns a promise, once the promise resolved/rejected,
9 * else once the callback has finished executing.
10 * The `onFinally` callback will _always_ be called, no matter if an error was thrown or not.
11 */
12export declare function handleCallbackErrors<Fn extends () => any>(fn: Fn, onError: (error: unknown) => void, onFinally?: () => void): ReturnType<Fn>;
13//# sourceMappingURL=handleCallbackErrors.d.ts.map
\No newline at end of file