I tried below function use co
and javascript promise test, the fulfill
will success return but reject
not, and catch error undefined. and the flow can't continue. why?
Error:
> at GeneratorFunctionPrototype.next (native)
at onFulfilled (/Users/../project/app/node_modules/co/index.js:65:19)
at runMicrotasksCallback (node.js:337:7)
at process._tickDomainCallback (node.js:381:11)
Code:
domain.run(function() {
var testPromise = function() {
return new Promise(function (fulfill, reject){
//reject('error');
reject(new Error('message'));
});
};
co(function *() {
var d = yield testPromise();
console.log(d);
res.send('fin');
}).catch(onerror);
function onerror(error) { console.error(error.stack); }
});
domain.on('error', function(error) { console.error(error); });