Skip to content

Commit

Permalink
fix(request): fix wrong handling of errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ro-ka committed Oct 31, 2014
1 parent e7b28b6 commit 4417cc5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/request.js
Expand Up @@ -41,14 +41,15 @@ Request.prototype.executeRequest = function(method, parameters, callback) {
});
res.on('end', function() {
var body = JSON.parse(chunks);
if (body.responseCode === 200) {
callback(null, body);
} else {

if (body.error) {
callback({
message: body.error,
code: body.responseCode
});
}

callback(null, body);
});
}
).on('error', function(error) {
Expand Down

0 comments on commit 4417cc5

Please sign in to comment.