Allow connector to report failure during initialization

This commit is contained in:
Raymond Feng 2013-09-12 13:31:21 -07:00
parent 2d072aa299
commit bf223320ea
1 changed files with 5 additions and 3 deletions

View File

@ -220,7 +220,7 @@ DataSource.prototype.setup = function(name, settings) {
} }
if (connector) { if (connector) {
var postInit = function postInit() { var postInit = function postInit(err, result) {
this._setupConnector(); this._setupConnector();
// we have an connector now? // we have an connector now?
@ -228,8 +228,10 @@ DataSource.prototype.setup = function(name, settings) {
throw new Error('Connector is not defined correctly: it should create `connector` member of dataSource'); throw new Error('Connector is not defined correctly: it should create `connector` member of dataSource');
} }
this.connected = true; this.connected = !err; // Connected now
this.emit('connected'); if(this.connected) {
this.emit('connected');
}
}.bind(this); }.bind(this);