diff --git a/lib/contributors/github.js b/lib/contributors/github.js index 0e77ac4..1c51dc8 100644 --- a/lib/contributors/github.js +++ b/lib/contributors/github.js @@ -13,6 +13,12 @@ module.exports = function getUserInfo(username) { .then(res => { var body = JSON.parse(res.body); var profile = body.blog || body.html_url; + + // Github throwing specific errors as 200... + if (!profile && body.message) { + throw new Error(body.message); + } + profile = profile.startsWith('http') ? profile : 'http://' + profile; return { diff --git a/lib/contributors/github.test.js b/lib/contributors/github.test.js index c3df530..297ab7e 100644 --- a/lib/contributors/github.test.js +++ b/lib/contributors/github.test.js @@ -10,6 +10,17 @@ test('should handle errors', t => { return t.throws(getUserInfo('nodisplayname')); }); +test('should handle github errors', t => { + nock('https://api.github.com') + .get('/users/nodisplayname') + .reply(200, { + message: 'API rate limit exceeded for 0.0.0.0. (But here\'s the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)', + documentation_url: 'https://developer.github.com/v3/#rate-limiting' + }); + + return t.throws(getUserInfo('nodisplayname')); +}); + test('should fill in the name when null is returned', t => { nock('https://api.github.com') .get('/users/nodisplayname')