From 11685d7a906eade7f586af1fcd08eaf270972b5e Mon Sep 17 00:00:00 2001 From: simple Date: Mon, 7 Apr 2025 03:10:33 +0900 Subject: [PATCH] fix: improve error handling for GitLab API rate limit exceeded --- index.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/index.ts b/index.ts index 1b9503e..dc1feeb 100644 --- a/index.ts +++ b/index.ts @@ -378,9 +378,19 @@ async function handleGitLabError( ): Promise { if (!response.ok) { const errorBody = await response.text(); - throw new Error( - `GitLab API error: ${response.status} ${response.statusText}\n${errorBody}` - ); + // Check specifically for Rate Limit error + 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}` + ); + } } }