MCPcopy
hub / github.com/di-sukharev/opencommit / isRateLimitError

Function isRateLimitError

src/utils/errors.ts:280–312  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

278
279// Detect rate limit errors (429)
280export function isRateLimitError(error: unknown): boolean {
281 if (error instanceof RateLimitError) {
282 return true;
283 }
284
285 if (error instanceof Error) {
286 const message = error.message.toLowerCase();
287
288 // Common patterns for rate limiting
289 if (
290 message.includes('rate limit') ||
291 message.includes('rate_limit') ||
292 message.includes('too many requests') ||
293 message.includes('throttle')
294 ) {
295 return true;
296 }
297
298 // Check for 429 status
299 if ('status' in (error as any) && (error as any).status === 429) {
300 return true;
301 }
302
303 if ('response' in (error as any)) {
304 const response = (error as any).response;
305 if (response?.status === 429) {
306 return true;
307 }
308 }
309 }
310
311 return false;
312}
313
314// Detect service unavailable errors (5xx)
315export function isServiceUnavailableError(error: unknown): boolean {

Callers 1

formatUserFriendlyErrorFunction · 0.70

Calls 2

toLowerCaseMethod · 0.80
includesMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…