diff options
-rw-r--r-- | test/utils/report_callback_errors.ts | 14 |
1 files changed, 14 insertions, 0 deletions
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; + }; +}; |