(error: unknown)
| 278 | |
| 279 | // Detect rate limit errors (429) |
| 280 | export 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) |
| 315 | export function isServiceUnavailableError(error: unknown): boolean { |
no test coverage detected
searching dependent graphs…