aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/test/utils/report_callback_errors.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/0x.js/test/utils/report_callback_errors.ts')
-rw-r--r--packages/0x.js/test/utils/report_callback_errors.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/packages/0x.js/test/utils/report_callback_errors.ts b/packages/0x.js/test/utils/report_callback_errors.ts
new file mode 100644
index 000000000..d471b2af2
--- /dev/null
+++ b/packages/0x.js/test/utils/report_callback_errors.ts
@@ -0,0 +1,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;
+ };
+};