@samitouri / QOS-React-2 / commits / 835d9c9f47

Handle github rate limiting response (#24573)

Make the error messages clearer when the API doesn't respond with 200.

Blake Friedman committed May 18, 2022 at 20:14 UTC 835d9c9f4724b71b429a6b7aaced6da1448e7fb8
1 file changed +8 -1
scripts/release/shared-commands/get-build-id-for-commit.js
+8 -1
@@ -23,7 +23,14 @@ async function getBuildIdForCommit(sha) {
23 );
24
25 if (!statusesResponse.ok) {
26 - throw Error('Could not find commit for: ' + sha);
26 + if (statusesResponse.status === 404) {
27 + throw Error('Could not find commit for: ' + sha);
28 + }
29 + const {message, documentation_url} = await statusesResponse.json();
30 + const msg = documentation_url
31 + ? `${message}\n\t${documentation_url}`
32 + : message;
33 + throw Error(msg);
34 }
35
36 const {statuses, state} = await statusesResponse.json();