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

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