Skip to content

Commit

Permalink
change unhandled exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
raksoras committed Dec 5, 2016
1 parent 105a63f commit 93df553
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/koroutine.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ function run(generator, timeout, ...rest) {
timer = null;
}
debug("Coroutine threw error: %s", e);
throw e;
}
finally {
current.context = null;
Expand Down
10 changes: 7 additions & 3 deletions test/koroutine.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function* testSequentialCalls(test) {
test.deepEqual(result, ['input-2', 'arg-1', 'arg-2']);

try {
yield* sequentialCallError(this, "error-1", 150);
yield* sequentialCallError(this, "error-1", 150);
} catch (e) {
test.equal(e.message, "error-1");
test.equal(e.cause, "exception");
Expand Down Expand Up @@ -211,7 +211,11 @@ exports['Test koroutine current context'] = function(test) {
function * testExceptionThrower(test) {
throw new Error("Uncaught Exception!");
}

exports['Test coroutine throwing uncaught exception'] = function(test) {
koroutine.run(testExceptionThrower, 1000, test);
test.done();
try {
koroutine.run(testExceptionThrower, 1000, test);
} catch (e) {
test.done();
}
}

0 comments on commit 93df553

Please sign in to comment.