Prevent Promise from intercepting our exceptions
parent
f7fe35fce2
commit
9510901f3f
9
index.js
9
index.js
|
@ -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); });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "gen-thread",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"author": {
|
||||
"name": "Vitaliy Filippov",
|
||||
"email": "vitalif@yourcmc.ru"
|
||||
|
|
Loading…
Reference in New Issue