Skip to content

Commit

Permalink
Add error handler test
Browse files Browse the repository at this point in the history
  • Loading branch information
raksoras committed Oct 4, 2017
1 parent df32068 commit 6479e8f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/koroutine.js
Expand Up @@ -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.');
Expand Down
8 changes: 8 additions & 0 deletions test/koroutine.test.js
Expand Up @@ -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);
Expand Down

0 comments on commit 6479e8f

Please sign in to comment.