From 438136813a3a94a74cb336a3a1c49d9d4f5616a0 Mon Sep 17 00:00:00 2001 From: Benoit Schweblin Date: Mon, 6 Jul 2015 11:52:11 +0100 Subject: [PATCH] Check err before reading res. Fixes #186. Generated javascript --- lib/octonode/auth.js | 4 +++- lib/octonode/gist.js | 2 +- src/octonode/auth.coffee | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/octonode/auth.js b/lib/octonode/auth.js index 2c1b014..8518678 100644 --- a/lib/octonode/auth.js +++ b/lib/octonode/auth.js @@ -112,7 +112,9 @@ 'User-Agent': 'octonode/0.3 (https://github.com/pksunkara/octonode) terminal/0.0' } }, function(err, res, body) { - if (res.statusCode === 404) { + if (err != null) { + return callback(err); + } else if (res.statusCode === 404) { return callback(new Error('Access token not found')); } else { body = qs.parse(body); diff --git a/lib/octonode/gist.js b/lib/octonode/gist.js index 04337ae..47d36eb 100644 --- a/lib/octonode/gist.js +++ b/lib/octonode/gist.js @@ -220,7 +220,7 @@ }); }; - Gist.prototype.deleteComment = function(id) { + Gist.prototype.deleteComment = function(id, cb) { return this.client.del("/gists/comments/" + id, {}, function(err, s, b, h) { if (err) { return cb(err); diff --git a/src/octonode/auth.coffee b/src/octonode/auth.coffee index 129cd31..4d0b51a 100644 --- a/src/octonode/auth.coffee +++ b/src/octonode/auth.coffee @@ -88,7 +88,9 @@ auth = module.exports = 'Content-Type': 'application/x-www-form-urlencoded' 'User-Agent': 'octonode/0.3 (https://github.com/pksunkara/octonode) terminal/0.0' , (err, res, body) -> - if res.statusCode is 404 + if err? + callback err + else if res.statusCode is 404 callback(new Error('Access token not found')) else body = qs.parse body