From 28999b3b458e715961439a8a227eb0019b6b4ed4 Mon Sep 17 00:00:00 2001 From: mscdex Date: Mon, 21 Jan 2013 04:49:52 -0500 Subject: [PATCH] add more detail to error object --- lib/imap.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/imap.js b/lib/imap.js index ac5a18c..de10c3c 100644 --- a/lib/imap.js +++ b/lib/imap.js @@ -642,6 +642,7 @@ ImapConnection.prototype.connect = function(loginCb) { if (line[0] === '+') { if (requests[0].cmd !== 'APPEND') { err = new Error('Unexpected continuation'); + err.level = 'protocol'; err.type = 'continuation'; err.request = cmdstr; } else @@ -651,6 +652,7 @@ ImapConnection.prototype.connect = function(loginCb) { // m[2]: resp-text-code // m[3]: message err = new Error(m[3]); + err.level = 'protocol'; err.type = 'failure'; err.code = m[2]; err.request = cmdstr; @@ -718,7 +720,9 @@ ImapConnection.prototype.connect = function(loginCb) { state.tmrConn = setTimeout(function() { state.conn.destroy(); state.conn = undefined; - loginCb(new Error('Connection timed out')); + var err = new Error('Connection timed out'); + err.level = 'timeout'; + loginCb(err); }, this._options.connTimeout); };