(error: APIError)
| 485 | } |
| 486 | |
| 487 | export function extractQuotaStatusFromError(error: APIError): void { |
| 488 | if ( |
| 489 | !shouldProcessRateLimits(isClaudeAISubscriber()) || |
| 490 | error.status !== 429 |
| 491 | ) { |
| 492 | return |
| 493 | } |
| 494 | |
| 495 | try { |
| 496 | let newLimits = { ...currentLimits } |
| 497 | if (error.headers) { |
| 498 | // Process headers (applies mocks from /mock-limits command if active) |
| 499 | const headersToUse = processRateLimitHeaders(error.headers) |
| 500 | rawUtilization = extractRawUtilization(headersToUse) |
| 501 | newLimits = computeNewLimitsFromHeaders(headersToUse) |
| 502 | |
| 503 | // Cache extra usage status (persists across sessions) |
| 504 | cacheExtraUsageDisabledReason(headersToUse) |
| 505 | } |
| 506 | // For errors, always set status to rejected even if headers are not present. |
| 507 | newLimits.status = 'rejected' |
| 508 | |
| 509 | if (!isEqual(currentLimits, newLimits)) { |
| 510 | emitStatusChange(newLimits) |
| 511 | } |
| 512 | } catch (e) { |
| 513 | logError(e as Error) |
| 514 | } |
| 515 | } |
| 516 |
no test coverage detected