From 6479e8f8d6d8d974e6cb1ef0c4d7f6dd0dccf97a Mon Sep 17 00:00:00 2001 From: raksoras Date: Tue, 3 Oct 2017 22:43:28 -0700 Subject: [PATCH] Add error handler test --- lib/koroutine.js | 4 ++-- test/koroutine.test.js | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/koroutine.js b/lib/koroutine.js index ec6f854..5f9061f 100644 --- a/lib/koroutine.js +++ b/lib/koroutine.js @@ -46,8 +46,8 @@ function stitchBreadcrumbs (error, breadcrumbs) { * Utility function that resumes the coroutine by throwing TimedOut exception when coroutine/callback/future does not finish before set timeout * @param {Function} either resume or future function * @param {String} 'coroutine' or 'callback' or 'future' - * @param {*} Name of the callback or future involved. optional. - * @param {*} timeout in milliseconds + * @param {String} Name of the callback or future involved. optional. + * @param {Number} timeout in milliseconds */ function timedOut (resume, type, name, timeout) { const e = new Error((type || '') + ' ' + (name || '') + ' did not finish within ' + timeout + ' ms.'); diff --git a/test/koroutine.test.js b/test/koroutine.test.js index 2720beb..3df3223 100644 --- a/test/koroutine.test.js +++ b/test/koroutine.test.js @@ -43,6 +43,14 @@ function* testSequentialCalls (test) { test.done(); } +function* alwaysThrows () { + throw new Error('ERROR'); +} + +exports['Test koroutine error handler function'] = function (test) { + koroutine.run(alwaysThrows(), {errorHandler: () => test.done()}); +}; + exports['Test koroutine.callback() fail when koroutine not started'] = function (test) { try { asyncCallSuccess('input-1', koroutine.callback(), 100);