From 46e2da24a472560a8ff0fc9b068ec017dd5173dd Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 9 Nov 2017 22:12:29 -0500 Subject: Add forgotten file --- test/utils/report_callback_errors.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 test/utils/report_callback_errors.ts (limited to 'test/utils/report_callback_errors.ts') diff --git a/test/utils/report_callback_errors.ts b/test/utils/report_callback_errors.ts new file mode 100644 index 000000000..d471b2af2 --- /dev/null +++ b/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; + }; +}; -- cgit v1.2.3