Skip to content

Commit

Permalink
refactor: use more clear retryer error message (2) (#3227)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerty541 committed Sep 14, 2023
1 parent 81f030f commit ef0ec6e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/common/retryer.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ const retryer = async (fetcher, variables, retries = 0) => {
throw new CustomError("No GitHub API tokens found", CustomError.NO_TOKENS);
}
if (retries > RETRIES) {
throw new CustomError("Maximum retries exceeded", CustomError.MAX_RETRY);
throw new CustomError(
"Downtime due to GitHub API rate limiting",
CustomError.MAX_RETRY,
);
}
try {
// try to fetch with the first token since RETRIES is 0 index i'm adding +1
Expand Down
3 changes: 2 additions & 1 deletion src/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ const CONSTANTS = {
};

const SECONDARY_ERROR_MESSAGES = {
MAX_RETRY: "Downtime due to GitHub API rate limiting",
MAX_RETRY:
"You can deploy own instance or wait until public will be no longer limited",
NO_TOKENS:
"Please add an env variable called PAT_1 with your GitHub API token in vercel",
USER_NOT_FOUND: "Make sure the provided username is not an organization",
Expand Down
4 changes: 2 additions & 2 deletions tests/retryer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ describe("Test Retryer", () => {
expect(res).toStrictEqual({ data: "ok" });
});

it("retryer should throw error if maximum retries reached", async () => {
it("retryer should throw specific error if maximum retries reached", async () => {
try {
await retryer(fetcherFail, {});
} catch (err) {
expect(fetcherFail).toBeCalledTimes(8);
expect(err.message).toBe("Maximum retries exceeded");
expect(err.message).toBe("Downtime due to GitHub API rate limiting");
}
});
});

0 comments on commit ef0ec6e

Please sign in to comment.