Skip to content

Commit 318f855

Browse files
Added verbose error message for a wrong status
If the server returns a 404 error message for the api url then the code will break when a subsequent method tries to analyse that response body. This way the error is clearer.
1 parent 971662b commit 318f855

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/api.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ function get(config, uri, callback){
2323
url: url,
2424
json: true
2525
}, function(err, res){
26+
if (res.statusCode != 200) {
27+
return callback(new Error("API seems to be broken: Status:" + res.statusCode));
28+
}
2629
callback(err, res.body);
2730
});
2831
}
@@ -93,4 +96,4 @@ function deleteHooks(config, repo_id, url, callback) {
9396
callback(err, deleted);
9497
});
9598
});
96-
}
99+
}

0 commit comments

Comments
 (0)