From f4d62e54e6f62453eb0fcf343440056762e3b53b Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Mon, 9 Sep 2013 10:12:12 -0700 Subject: [PATCH 1/2] Add error stack trace for ValidationError The issue was initially reported by SLA-370. --- lib/validations.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/validations.js b/lib/validations.js index 40f6797b..19ecb987 100644 --- a/lib/validations.js +++ b/lib/validations.js @@ -1,3 +1,4 @@ +var util = require('util'); /** * Module exports */ @@ -604,6 +605,7 @@ function ValidationError(obj) { this.context = obj && obj.constructor && obj.constructor.modelName; Error.call(this); -}; + Error.captureStackTrace(this, this.constructor); +} -ValidationError.prototype.__proto__ = Error.prototype; +util.inherits(ValidationError, Error); From bf223320ea8b16119a2ec162e88e8dd1298848c1 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Thu, 12 Sep 2013 13:31:21 -0700 Subject: [PATCH 2/2] Allow connector to report failure during initialization --- lib/datasource.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/datasource.js b/lib/datasource.js index 2d7215fb..027eb866 100644 --- a/lib/datasource.js +++ b/lib/datasource.js @@ -220,7 +220,7 @@ DataSource.prototype.setup = function(name, settings) { } if (connector) { - var postInit = function postInit() { + var postInit = function postInit(err, result) { this._setupConnector(); // 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'); } - this.connected = true; - this.emit('connected'); + this.connected = !err; // Connected now + if(this.connected) { + this.emit('connected'); + } }.bind(this);