Skip to content

Commit 1a30d2c

Browse files
committed
fix: improve error handling for GitLab API rate limit exceeded
1 parent 04d125f commit 1a30d2c

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

index.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,19 @@ async function handleGitLabError(
378378
): Promise<void> {
379379
if (!response.ok) {
380380
const errorBody = await response.text();
381-
throw new Error(
382-
`GitLab API error: ${response.status} ${response.statusText}\n${errorBody}`
383-
);
381+
// Check specifically for Rate Limit error
382+
if (response.status === 403 && errorBody.includes("User API Key Rate limit exceeded")) {
383+
console.error("GitLab API Rate Limit Exceeded:", errorBody);
384+
console.log("User API Key Rate limit exceeded. Please try again later.");
385+
throw new Error(
386+
`GitLab API Rate Limit Exceeded: ${errorBody}`
387+
);
388+
} else {
389+
// Handle other API errors
390+
throw new Error(
391+
`GitLab API error: ${response.status} ${response.statusText}\n${errorBody}`
392+
);
393+
}
384394
}
385395
}
386396

0 commit comments

Comments
 (0)