From ab41caa0c76ed3f54886b591bd41e530f59c1541 Mon Sep 17 00:00:00 2001 From: David Menendez Date: Fri, 23 Feb 2018 01:46:07 -0600 Subject: [PATCH] fix: surface the message when the check api returns an error (#85) --- src/util/check.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/util/check.js b/src/util/check.js index 034b1a8..d87b08e 100644 --- a/src/util/check.js +++ b/src/util/check.js @@ -25,6 +25,9 @@ function getContributorsPage(url) { }) .then(res => { const body = JSON.parse(res.body) + if (res.statusCode >= 400) { + throw new Error(body.message) + } const contributorsIds = body.map(contributor => contributor.login) const nextLink = getNextLink(res.headers.link) @@ -39,8 +42,6 @@ function getContributorsPage(url) { } module.exports = function getContributorsFromGithub(owner, name) { - const url = `https://api.github.com/repos/${owner}/${ - name - }/contributors?per_page=100` + const url = `https://api.github.com/repos/${owner}/${name}/contributors?per_page=100` return getContributorsPage(url) }