不要怂,就是干,撸起袖子干!

Commit a64c0371 by Mick Hansen

Merge pull request #2552 from defunctzombie/fix_error_message

keep original error message when wrapping in DatabaseError
2 parents 141946cc 79a9c326
Showing with 9 additions and 1 deletions
......@@ -72,7 +72,7 @@ error.ValidationError.prototype.errors;
* @constructor
*/
error.DatabaseError = function (parent) {
error.BaseError.apply(this, arguments);
error.BaseError.apply(this, [parent.message]);
this.name = 'SequelizeDatabaseError';
this.parent = parent;
......
......@@ -55,6 +55,14 @@ describe(Support.getTestDialectTeaser("Sequelize Errors"), function () {
expect(matches).to.have.lengthOf(1);
expect(matches[0]).to.have.property('message', 'invalid');
});
it('SequelizeDatabaseError should keep original message', function() {
var orig = new Error('original database error message');
var databaseError = new Sequelize.DatabaseError(orig);
expect(databaseError).to.have.property('parent');
expect(databaseError.name).to.equal('SequelizeDatabaseError');
expect(databaseError.message).to.equal('original database error message');
});
});
describe('Constraint error', function () {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!