Handle github rate limiting response (#24573)

Make the error messages clearer when the API doesn't respond with 200.
This commit is contained in:
Blake Friedman
2022-05-18 15:14:27 -04:00
committed by GitHub
parent e25a98b8a6
commit 61bca46988
@@ -23,7 +23,14 @@ async function getBuildIdForCommit(sha) {
);
if (!statusesResponse.ok) {
throw Error('Could not find commit for: ' + sha);
if (statusesResponse.status === 404) {
throw Error('Could not find commit for: ' + sha);
}
const {message, documentation_url} = await statusesResponse.json();
const msg = documentation_url
? `${message}\n\t${documentation_url}`
: message;
throw Error(msg);
}
const {statuses, state} = await statusesResponse.json();