You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Add .command_used to errors thrown by the parser
This commit is contained in:
1
index.js
1
index.js
@@ -509,6 +509,7 @@ RedisClient.prototype.on_data = function (data) {
|
||||
|
||||
RedisClient.prototype.return_error = function (err) {
|
||||
var command_obj = this.command_queue.shift(), queue_len = this.command_queue.length;
|
||||
err.command_used = command_obj.command.toUpperCase();
|
||||
|
||||
if (this.pub_sub_mode === false && queue_len === 0) {
|
||||
this.command_queue = new Queue();
|
||||
|
@@ -39,8 +39,9 @@ describe("client authentication", function () {
|
||||
|
||||
client = redis.createClient.apply(redis.createClient, args);
|
||||
|
||||
client.once('error', function (error) {
|
||||
assert.ok(/ERR invalid password/.test(error));
|
||||
client.once('error', function (err) {
|
||||
assert.strictEqual(err.command_used, 'AUTH');
|
||||
assert.ok(/ERR invalid password/.test(err.message));
|
||||
return done();
|
||||
});
|
||||
|
||||
|
@@ -94,6 +94,7 @@ describe("The 'select' method", function () {
|
||||
assert.strictEqual(client.selected_db, null, "default db should be null");
|
||||
|
||||
client.on('error', function (err) {
|
||||
assert.strictEqual(err.command_used, 'SELECT');
|
||||
assert.equal(err.message, 'ERR invalid DB index');
|
||||
done();
|
||||
});
|
||||
|
Reference in New Issue
Block a user