I want to hold the error from func()
reject
, not direct to onError()
by choise,
Before I always let func()
reso
co
supports try/catch
:
co(function* () {
try{
yield func();
}
catch {
// if reject catch here, not direct to onError
}
yield func();
// if reject don't catch here just direct to onError
}).then(function (response) {
response = JSON.stringify(response);
res.send(response);
}, function (err) {
onError(err);
});
See docs : https://www.npmjs.com/package/co#examples