Prevent Promise from intercepting our exceptions

master
Vitaliy Filippov 2016-08-23 19:04:24 +03:00
parent f7fe35fce2
commit 9510901f3f
2 changed files with 7 additions and 4 deletions

View File

@ -101,10 +101,13 @@ function callGen(thread, method, arg)
else if (typeof v.value == 'object' && v.value.then)
{
// check if v.value is a Promise
var cb = threadCallback.call(thread);
v.value.then(cb, function(error)
v.value.then(function(value)
{
callGen(thread, 'throw', error);
// use process.nextTick so Promise does not intercept our exceptions
process.nextTick(function() { callGen(thread, 'next', value); });
}, function(error)
{
process.nextTick(function() { callGen(thread, 'throw', error); });
});
}
}

View File

@ -1,6 +1,6 @@
{
"name": "gen-thread",
"version": "1.0.1",
"version": "1.0.2",
"author": {
"name": "Vitaliy Filippov",
"email": "vitalif@yourcmc.ru"