Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add GitHub REST API error to CustomError class #3272

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,13 +399,16 @@ const CONSTANTS = {
ERROR_CACHE_SECONDS: TEN_MINUTES,
};

const TRY_AGAING_LATER = "Please try again later";

const SECONDARY_ERROR_MESSAGES = {
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",
GRAPHQL_ERROR: "Please try again later",
GRAPHQL_ERROR: TRY_AGAING_LATER,
GITHUB_REST_API_ERROR: TRY_AGAING_LATER,
WAKATIME_USER_NOT_FOUND: "Make sure you have a public WakaTime profile",
};

Expand All @@ -427,6 +430,7 @@ class CustomError extends Error {
static NO_TOKENS = "NO_TOKENS";
static USER_NOT_FOUND = "USER_NOT_FOUND";
static GRAPHQL_ERROR = "GRAPHQL_ERROR";
static GITHUB_REST_API_ERROR = "GITHUB_REST_API_ERROR";
static WAKATIME_ERROR = "WAKATIME_ERROR";
}

Expand Down
2 changes: 1 addition & 1 deletion src/fetchers/stats-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const totalCommitsFetcher = async (username) => {
if (!totalCount || isNaN(totalCount)) {
throw new CustomError(
"Could not fetch total commits.",
CustomError.GRAPHQL_ERROR,
CustomError.GITHUB_REST_API_ERROR,
);
}
return totalCount;
Expand Down
Loading