protocol/packages/0x.js/test/utils/report_callback_errors.ts
2017-11-23 15:13:38 -06:00

15 lines
369 B
TypeScript

import { DoneCallback } from '../../src/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;
};
};