From 37cdbc110deb9f5fdfcb015103ee003a41e592b5 Mon Sep 17 00:00:00 2001 From: Trevor Livingston Date: Tue, 3 Nov 2015 15:34:01 -0600 Subject: [PATCH] added name and code to timeout error --- lib/breaker.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/breaker.js b/lib/breaker.js index 03b07be..969a95b 100644 --- a/lib/breaker.js +++ b/lib/breaker.js @@ -89,13 +89,14 @@ Breaker.prototype._run = function _run(/*args...n, callback*/) { start = Date.now(); timer = setTimeout(function ontimeout() { - + var error = new Error('Command timeout.'); + error.name = 'commandTimeout'; + error.code = 'ETIMEDOUT'; timer = undefined; self._pendingClose = false; self.emit('timeout'); self._onFailure(); - callback(new Error('Command timeout.')); - + callback(error); }, this.settings.timeout); timer.unref();