aboutsummaryrefslogtreecommitdiffstats
path: root/test/utils/report_callback_errors.ts
blob: d471b2af2d289c83fc44cb077231c96adf5f86af (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { DoneCallback } from '../../src/types';

export const reportCallbackErrors = (done: DoneCallback) => {
    return (f: (...args: any[]) => void) => {
        const wrapped = (...args: any[]) => {
            try {
                f(...args);
            } catch (err) {
                done(err);
            }
        };
        return wrapped;
    };
};