Files
gemini-cli/packages/core/src/utils/quotaErrorDetection.ts

36 lines
770 B
TypeScript

/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import type { StructuredError } from '../core/turn.js';
export interface ApiError {
error: {
code: number;
message: string;
status: string;
details: unknown[];
};
}
export function isApiError(error: unknown): error is ApiError {
return (
typeof error === 'object' &&
error !== null &&
'error' in error &&
typeof (error as ApiError).error === 'object' &&
'message' in (error as ApiError).error
);
}
export function isStructuredError(error: unknown): error is StructuredError {
return (
typeof error === 'object' &&
error !== null &&
'message' in error &&
typeof (error as StructuredError).message === 'string'
);
}