Skip to content

Commit bc019fd

Browse files
committed
Fix: handle rate limit error
1 parent 12eb36d commit bc019fd

File tree

2 files changed

+35
-18
lines changed

2 files changed

+35
-18
lines changed

build/index.js

Lines changed: 14 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ import {
1717
validate,
1818
} from "./common/utils";
1919
import { getRateLimit } from "./requests/getRateLimit";
20-
import {
21-
sendActionError,
22-
sendActionRun,
23-
} from "./analytics";
20+
import { sendActionError, sendActionRun } from "./analytics";
2421

2522
async function main() {
2623
try {
@@ -34,11 +31,17 @@ async function main() {
3431
);
3532
return;
3633
}
37-
const rateLimitAtBeginning = await getRateLimit();
38-
console.log(
39-
"RATE LIMIT REMAINING BEFORE REQUESTS: ",
40-
rateLimitAtBeginning.data.rate.remaining
41-
);
34+
try {
35+
const rateLimitAtBeginning = await getRateLimit();
36+
console.log(
37+
"RATE LIMIT REMAINING BEFORE REQUESTS: ",
38+
rateLimitAtBeginning.data.rate.remaining
39+
);
40+
} catch (error) {
41+
console.log(
42+
"Rate limit could not be retrieved at the beginning of the action"
43+
);
44+
}
4245

4346
const ownersRepos = getOwnersRepositories();
4447
const organizationsRepos = await getOrganizationsRepositories();
@@ -93,11 +96,15 @@ async function main() {
9396
console.log("Calculation complete. Generating markdown.");
9497
await createOutput(preparedData);
9598

96-
const rateLimitAtEnd = await getRateLimit();
97-
console.log(
98-
"RATE LIMIT REMAINING AFTER REQUESTS: ",
99-
rateLimitAtEnd.data.rate.remaining
100-
);
99+
try {
100+
const rateLimitAtEnd = await getRateLimit();
101+
console.log(
102+
"RATE LIMIT REMAINING AFTER REQUESTS: ",
103+
rateLimitAtEnd.data.rate.remaining
104+
);
105+
} catch (error) {
106+
console.log("Rate limit could not be retrieved at the end of the action");
107+
}
101108
} catch (error) {
102109
sendActionError(error as Error);
103110
throw error;

0 commit comments

Comments
 (0)