Skip to content

Commit 9cb8bc0

Browse files
authored
refactor(github): add retry count to fetchWithRetry error message (JhaSourav07#577)
Co-authored-by: Sourav <souravkjha2007@gmail.com>
2 parents 7bdf8c4 + 89c33d2 commit 9cb8bc0

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

lib/github.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ describe('fetchGitHubContributions', () => {
107107
vi.mocked(fetch).mockResolvedValue(mockResponse({ message: 'Internal Server Error' }, 500));
108108

109109
await expect(fetchGitHubContributions('octocat')).rejects.toThrow(
110-
'GitHub GraphQL API returned status 500'
110+
'GitHub GraphQL API returned status 500 after 3 retries'
111111
);
112112
});
113113

lib/github.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ export async function fetchGitHubContributions(
194194

195195
if (!res.ok) {
196196
if (res.status === 401) throw new Error('GitHub PAT is invalid or missing');
197-
throw new Error(`GitHub GraphQL API returned status ${res.status}`);
197+
throw new Error(
198+
`GitHub GraphQL API returned status ${res.status} after ${MAX_RETRIES} retries`
199+
);
198200
}
199201

200202
const data: GitHubContributionResponse = await res.json();

0 commit comments

Comments
 (0)