(error: APIError)
| 503 | } |
| 504 | |
| 505 | export function extractQuotaStatusFromError(error: APIError): void { |
| 506 | if ( |
| 507 | !shouldProcessClaudeAiRateLimitsForSession( |
| 508 | getAuthRuntime().getCurrentSession(), |
| 509 | ) || |
| 510 | error.status !== 429 |
| 511 | ) { |
| 512 | return |
| 513 | } |
| 514 | |
| 515 | try { |
| 516 | let newLimits = { ...currentLimits } |
| 517 | if (error.headers) { |
| 518 | // Process headers (applies mocks from /mock-limits command if active) |
| 519 | const headersToUse = processRateLimitHeaders(error.headers) |
| 520 | rawUtilization = extractRawUtilization(headersToUse) |
| 521 | newLimits = computeNewLimitsFromHeaders(headersToUse) |
| 522 | |
| 523 | // Cache extra usage status (persists across sessions) |
| 524 | cacheExtraUsageDisabledReason(headersToUse) |
| 525 | } |
| 526 | // For errors, always set status to rejected even if headers are not present. |
| 527 | newLimits.status = 'rejected' |
| 528 | |
| 529 | if (!isEqual(currentLimits, newLimits)) { |
| 530 | emitStatusChange(newLimits) |
| 531 | } |
| 532 | } catch (e) { |
| 533 | logError(e as Error) |
| 534 | } |
| 535 | } |
no test coverage detected