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

Commit 55946ad9 by Jan Aagaard Meier

Merge pull request #4209 from seanjh/throw-original-auth-error

Throw the original error from authenticate
2 parents 892619e4 54686a37
...@@ -931,9 +931,7 @@ Sequelize.prototype.drop = function(options) { ...@@ -931,9 +931,7 @@ Sequelize.prototype.drop = function(options) {
* @return {Promise} * @return {Promise}
*/ */
Sequelize.prototype.authenticate = function(options) { Sequelize.prototype.authenticate = function(options) {
return this.query('SELECT 1+1 AS result', Utils._.assign({ raw: true, plain: true }, options)).return().catch(function(err) { return this.query('SELECT 1+1 AS result', Utils._.assign({ raw: true, plain: true }, options)).return();
throw new Error(err);
});
}; };
Sequelize.prototype.databaseVersion = function(options) { Sequelize.prototype.databaseVersion = function(options) {
......
...@@ -106,6 +106,18 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() { ...@@ -106,6 +106,18 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() {
}); });
}); });
it('triggers an actual RangeError or ConnectionError', function() {
return this
.sequelizeWithInvalidConnection
.authenticate()
.catch(function(err) {
expect(
err instanceof RangeError ||
err instanceof Sequelize.ConnectionError
).to.be.ok;
});
});
it('triggers the actual adapter error', function() { it('triggers the actual adapter error', function() {
return this return this
.sequelizeWithInvalidConnection .sequelizeWithInvalidConnection
...@@ -114,10 +126,10 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() { ...@@ -114,10 +126,10 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() {
expect( expect(
err.message.match(/connect ECONNREFUSED/) || err.message.match(/connect ECONNREFUSED/) ||
err.message.match(/invalid port number/) || err.message.match(/invalid port number/) ||
err.message.match(/RangeError: Port should be > 0 and < 65536/) || err.message.match(/Port should be > 0 and < 65536/) ||
err.message.match(/RangeError: port should be > 0 and < 65536/) || err.message.match(/port should be > 0 and < 65536/) ||
err.message.match(/RangeError: port should be >= 0 and < 65536: 99999/) || err.message.match(/port should be >= 0 and < 65536: 99999/) ||
err.message.match(/ConnectionError: Login failed for user/) err.message.match(/Login failed for user/)
).to.be.ok; ).to.be.ok;
}); });
}); });
...@@ -137,6 +149,15 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() { ...@@ -137,6 +149,15 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() {
}); });
}); });
it('triggers an actual sequlize error', function() {
return this
.sequelizeWithInvalidCredentials
.authenticate()
.catch(function(err) {
expect(err).to.be.instanceof(Sequelize.Error);
});
});
it('triggers the error event when using replication', function() { it('triggers the error event when using replication', function() {
return new Sequelize('sequelize', null, null, { return new Sequelize('sequelize', null, null, {
replication: { replication: {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!