Merge pull request #15 from strongloop/SLA-506
Allow connector to report failure during initialization
This commit is contained in:
commit
2e85f3f406
|
@ -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
|
||||||
|
if(this.connected) {
|
||||||
this.emit('connected');
|
this.emit('connected');
|
||||||
|
}
|
||||||
|
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
var util = require('util');
|
||||||
/**
|
/**
|
||||||
* Module exports
|
* Module exports
|
||||||
*/
|
*/
|
||||||
|
@ -604,6 +605,7 @@ function ValidationError(obj) {
|
||||||
this.context = obj && obj.constructor && obj.constructor.modelName;
|
this.context = obj && obj.constructor && obj.constructor.modelName;
|
||||||
|
|
||||||
Error.call(this);
|
Error.call(this);
|
||||||
};
|
Error.captureStackTrace(this, this.constructor);
|
||||||
|
}
|
||||||
|
|
||||||
ValidationError.prototype.__proto__ = Error.prototype;
|
util.inherits(ValidationError, Error);
|
||||||
|
|
Loading…
Reference in New Issue