MCPcopy Create free account
hub / github.com/Noumena-Network/code / extractQuotaStatusFromError

Function extractQuotaStatusFromError

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

Source from the content-addressed store, hash-verified

503}
504
505export 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}

Callers 2

checkQuotaStatusFunction · 0.85
queryModelFunction · 0.85

Calls 9

getAuthRuntimeFunction · 0.85
processRateLimitHeadersFunction · 0.85
extractRawUtilizationFunction · 0.85
emitStatusChangeFunction · 0.85
getCurrentSessionMethod · 0.65
logErrorFunction · 0.50

Tested by

no test coverage detected