MCPcopy Index your code
hub / github.com/simstudioai/sim / isRateLimitError

Function isRateLimitError

apps/sim/tools/index.ts:369–382  ·  view source on GitHub ↗

* Check if an error is a rate limit (throttling) or quota exhaustion error. * Some providers (e.g. Perplexity) return 401/403 with "insufficient_quota" * instead of the standard 429, so we also inspect the error message.

(error: unknown)

Source from the content-addressed store, hash-verified

367 * instead of the standard 429, so we also inspect the error message.
368 */
369function isRateLimitError(error: unknown): boolean {
370 if (error && typeof error === 'object') {
371 const status = (error as { status?: number }).status
372 if (status === 429 || status === 503) return true
373
374 if (status === 401 || status === 403) {
375 const message = ((error as { message?: string }).message || '').toLowerCase()
376 if (message.includes('quota') || message.includes('rate limit')) {
377 return true
378 }
379 }
380 }
381 return false
382}
383
384/**
385 * Map a thrown tool error to a hosted-key failure reason for metrics. Mirrors

Callers 1

executeWithRetryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected