From 31c22be6b93b4bd4f4ada7c9382e0ecc19def456 Mon Sep 17 00:00:00 2001 From: bobrik Date: Mon, 15 Jul 2013 23:10:54 +0400 Subject: [PATCH] String is not an error --- index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 7a93a58dc8..395c23f01d 100644 --- a/index.js +++ b/index.js @@ -137,12 +137,15 @@ RedisClient.prototype.unref = function () { // flush offline_queue and command_queue, erroring any items with a callback first RedisClient.prototype.flush_and_error = function (message) { - var command_obj; + var command_obj, error; + + error = new Error(message); + while (this.offline_queue.length > 0) { command_obj = this.offline_queue.shift(); if (typeof command_obj.callback === "function") { try { - command_obj.callback(message); + command_obj.callback(error); } catch (callback_err) { process.nextTick(function () { throw callback_err; @@ -156,7 +159,7 @@ RedisClient.prototype.flush_and_error = function (message) { command_obj = this.command_queue.shift(); if (typeof command_obj.callback === "function") { try { - command_obj.callback(message); + command_obj.callback(error); } catch (callback_err) { process.nextTick(function () { throw callback_err;