From aed6d2b043715e1a37c45a6293935c25c023ebce Mon Sep 17 00:00:00 2001 From: Patrick Mooney Date: Fri, 27 Jun 2014 17:28:04 -0500 Subject: [PATCH] Add optional error arg to client destroy event --- lib/client/client.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/client/client.js b/lib/client/client.js index 78f8a47..0df8e1a 100644 --- a/lib/client/client.js +++ b/lib/client/client.js @@ -700,9 +700,11 @@ Client.prototype.unbind = function unbind(callback) { * possible to initiate new requests after a call to unbind since the client * will attempt to reconnect in order to fulfill the request. * - * Calling destroy will prevent any further reconnections from occuring. + * Calling destroy will prevent any further reconnection from occurring. + * + * @param {Object} err (Optional) error that was cause of client destruction */ -Client.prototype.destroy = function destroy() { +Client.prototype.destroy = function destroy(err) { this.destroyed = true; this.queue.freeze(); // Purge any queued requests which are now meaningless @@ -716,7 +718,7 @@ Client.prototype.destroy = function destroy() { } else if (this.socket) { this.socket.destroy(); } - this.emit('destroy'); + this.emit('destroy', err); };