Skip to content

Commit 89c33d2

Browse files
author
Your Name
committed
refactor(github): add retry count to fetchWithRetry error message
1 parent e15a46a commit 89c33d2

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
@@ -106,7 +106,7 @@ describe('fetchGitHubContributions', () => {
106106
vi.mocked(fetch).mockResolvedValue(mockResponse({ message: 'Internal Server Error' }, 500));
107107

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

lib/github.ts

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

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

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

0 commit comments

Comments
 (0)