Replace all the .catch() by try/catch
Because .catch()
breaks the stack trace, this avoid us to deeply understand the cause of an error.
Example:
return co(function*() {
yield server.initWithDAL();
yield configure(server, server.conf || {});
yield server.loadConf();
cbArgs.length--;
cbArgs[cbArgs.length++] = server;
cbArgs[cbArgs.length++] = server.conf;
onService && onService(server);
return callback.apply(that, cbArgs);
})
.catch(function (err) {
server.disconnect();
throw Error(err);
});
Should be replaced by:
return co(function*() {
try {
yield server.initWithDAL();
yield configure(server, server.conf || {});
yield server.loadConf();
cbArgs.length--;
cbArgs[cbArgs.length++] = server;
cbArgs[cbArgs.length++] = server.conf;
onService && onService(server);
return callback.apply(that, cbArgs);
} catch (e) {
server.disconnect();
throw e;
}
});