MCPcopy
hub / github.com/codeaashu/claude-code / extractQuotaStatusFromError

Function extractQuotaStatusFromError

src/services/claudeAiLimits.ts:487–515  ·  view source on GitHub ↗
(error: APIError)

Source from the content-addressed store, hash-verified

485}
486
487export 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

Callers 2

checkQuotaStatusFunction · 0.85
queryModelFunction · 0.85

Calls 8

shouldProcessRateLimitsFunction · 0.85
processRateLimitHeadersFunction · 0.85
extractRawUtilizationFunction · 0.85
emitStatusChangeFunction · 0.85
isClaudeAISubscriberFunction · 0.50
logErrorFunction · 0.50

Tested by

no test coverage detected