mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-25 13:30:45 -07:00
format file
This commit is contained in:
@@ -234,7 +234,7 @@ export function parseGoogleApiError(error: unknown): GoogleApiError | null {
|
||||
}
|
||||
// Basic structural check before casting.
|
||||
// Since the proto definitions are loose, we primarily rely on @type presence.
|
||||
|
||||
|
||||
if (typeof detailObj['@type'] === 'string') {
|
||||
// We can just cast it; the consumer will have to switch on @type
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
|
||||
@@ -242,6 +242,17 @@ export function classifyGoogleError(error: unknown): unknown {
|
||||
);
|
||||
}
|
||||
|
||||
// Centralized check for RESOURCE_EXHAUSTED errors
|
||||
if (
|
||||
googleApiError?.status === 'RESOURCE_EXHAUSTED' &&
|
||||
(status === 429 || status === 499)
|
||||
) {
|
||||
const errorMessage =
|
||||
googleApiError?.message ||
|
||||
(error instanceof Error ? error.message : String(error));
|
||||
return new TerminalQuotaError(errorMessage, googleApiError);
|
||||
}
|
||||
|
||||
if (
|
||||
!googleApiError ||
|
||||
(googleApiError.code !== 429 && googleApiError.code !== 499) ||
|
||||
@@ -269,12 +280,6 @@ export function classifyGoogleError(error: unknown): unknown {
|
||||
// Fallback: If it is a 429 or 499 but doesn't have a specific "retry in" message,
|
||||
// assume it is a temporary rate limit and retry after 5 sec (same as DEFAULT_RETRY_OPTIONS).
|
||||
|
||||
// However, if the API explicitly returns RESOURCE_EXHAUSTED without details,
|
||||
// it indicates a hard quota exhaustion rather than a transient rate limit.
|
||||
if (googleApiError?.status === 'RESOURCE_EXHAUSTED') {
|
||||
return new TerminalQuotaError(errorMessage, googleApiError);
|
||||
}
|
||||
|
||||
return new RetryableQuotaError(
|
||||
errorMessage,
|
||||
googleApiError ?? {
|
||||
@@ -413,10 +418,6 @@ export function classifyGoogleError(error: unknown): unknown {
|
||||
googleApiError?.message ||
|
||||
(error instanceof Error ? error.message : String(error));
|
||||
|
||||
if (googleApiError?.status === 'RESOURCE_EXHAUSTED') {
|
||||
return new TerminalQuotaError(errorMessage, googleApiError);
|
||||
}
|
||||
|
||||
return new RetryableQuotaError(
|
||||
errorMessage,
|
||||
googleApiError ?? {
|
||||
|
||||
Reference in New Issue
Block a user