Skip to content

Commit 30fc01a

Browse files
author
Alex Fernández
committed
Improved error message when user lacks admin rights.
1 parent 1cf107f commit 30fc01a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/api.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,14 @@ function createHooks(reponame, url, secret, token, callback) {
5050
.end(function (err, res) {
5151
if (err) return callback(err);
5252

53+
var badStatusErr;
54+
if (res.statusCode === 404) {
55+
badStatusErr = new Error('Cannot create webhooks; are you sure you have admin rights?');
56+
badStatusErr.statusCode = res.statusCode;
57+
return callback(badStatusErr);
58+
}
5359
if (res.statusCode !== 201) {
54-
var badStatusErr = new Error('Bad status code: ' + res.statusCode);
60+
badStatusErr = new Error('Bad status code: ' + res.statusCode);
5561
badStatusErr.statusCode = res.statusCode;
5662
return callback(badStatusErr);
5763
}

0 commit comments

Comments
 (0)