fix: improve error handling for GitLab API rate limit exceeded

This commit is contained in:
simple
2025-04-07 03:10:33 +09:00
parent a7a8149008
commit 11685d7a90

View File

@ -378,9 +378,19 @@ async function handleGitLabError(
): Promise<void> { ): Promise<void> {
if (!response.ok) { if (!response.ok) {
const errorBody = await response.text(); const errorBody = await response.text();
throw new Error( // Check specifically for Rate Limit error
`GitLab API error: ${response.status} ${response.statusText}\n${errorBody}` if (response.status === 403 && errorBody.includes("User API Key Rate limit exceeded")) {
); console.error("GitLab API Rate Limit Exceeded:", errorBody);
console.log("User API Key Rate limit exceeded. Please try again later.");
throw new Error(
`GitLab API Rate Limit Exceeded: ${errorBody}`
);
} else {
// Handle other API errors
throw new Error(
`GitLab API error: ${response.status} ${response.statusText}\n${errorBody}`
);
}
} }
} }