move errorParsing.ts to core (#6159)
This commit is contained in:
parent
9c7fb870c1
commit
b61a63aef4
|
@ -13,10 +13,10 @@ import {
|
|||
isTelemetrySdkInitialized,
|
||||
GeminiEventType,
|
||||
ToolErrorType,
|
||||
parseAndFormatApiError,
|
||||
} from '@google/gemini-cli-core';
|
||||
import { Content, Part, FunctionCall } from '@google/genai';
|
||||
|
||||
import { parseAndFormatApiError } from './ui/utils/errorParsing.js';
|
||||
import { ConsolePatcher } from './ui/utils/ConsolePatcher.js';
|
||||
|
||||
export async function runNonInteractive(
|
||||
|
|
|
@ -51,6 +51,7 @@ const MockedGeminiClientClass = vi.hoisted(() =>
|
|||
const MockedUserPromptEvent = vi.hoisted(() =>
|
||||
vi.fn().mockImplementation(() => {}),
|
||||
);
|
||||
const mockParseAndFormatApiError = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock('@google/gemini-cli-core', async (importOriginal) => {
|
||||
const actualCoreModule = (await importOriginal()) as any;
|
||||
|
@ -59,6 +60,7 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
|
|||
GitService: vi.fn(),
|
||||
GeminiClient: MockedGeminiClientClass,
|
||||
UserPromptEvent: MockedUserPromptEvent,
|
||||
parseAndFormatApiError: mockParseAndFormatApiError,
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -127,11 +129,6 @@ vi.mock('./slashCommandProcessor.js', () => ({
|
|||
handleSlashCommand: vi.fn().mockReturnValue(false),
|
||||
}));
|
||||
|
||||
const mockParseAndFormatApiError = vi.hoisted(() => vi.fn());
|
||||
vi.mock('../utils/errorParsing.js', () => ({
|
||||
parseAndFormatApiError: mockParseAndFormatApiError,
|
||||
}));
|
||||
|
||||
// --- END MOCKS ---
|
||||
|
||||
describe('mergePartListUnions', () => {
|
||||
|
|
|
@ -25,6 +25,7 @@ import {
|
|||
UnauthorizedError,
|
||||
UserPromptEvent,
|
||||
DEFAULT_GEMINI_FLASH_MODEL,
|
||||
parseAndFormatApiError,
|
||||
} from '@google/gemini-cli-core';
|
||||
import { type Part, type PartListUnion, FinishReason } from '@google/genai';
|
||||
import {
|
||||
|
@ -37,7 +38,6 @@ import {
|
|||
ToolCallStatus,
|
||||
} from '../types.js';
|
||||
import { isAtCommand } from '../utils/commandUtils.js';
|
||||
import { parseAndFormatApiError } from '../utils/errorParsing.js';
|
||||
import { useShellCommandProcessor } from './shellCommandProcessor.js';
|
||||
import { handleAtCommand } from './atCommandProcessor.js';
|
||||
import { findLastSafeSplitPoint } from '../utils/markdownUtilities.js';
|
||||
|
|
|
@ -41,6 +41,7 @@ export * from './utils/systemEncoding.js';
|
|||
export * from './utils/textUtils.js';
|
||||
export * from './utils/formatters.js';
|
||||
export * from './utils/filesearch/fileSearch.js';
|
||||
export * from './utils/errorParsing.js';
|
||||
|
||||
// Export services
|
||||
export * from './services/fileDiscoveryService.js';
|
||||
|
|
|
@ -6,12 +6,11 @@
|
|||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { parseAndFormatApiError } from './errorParsing.js';
|
||||
import {
|
||||
AuthType,
|
||||
UserTierId,
|
||||
DEFAULT_GEMINI_FLASH_MODEL,
|
||||
isProQuotaExceededError,
|
||||
} from '@google/gemini-cli-core';
|
||||
import { isProQuotaExceededError } from './quotaErrorDetection.js';
|
||||
import { DEFAULT_GEMINI_FLASH_MODEL } from '../config/models.js';
|
||||
import { UserTierId } from '../code_assist/types.js';
|
||||
import { AuthType } from '../core/contentGenerator.js';
|
||||
import { StructuredError } from '../core/turn.js';
|
||||
|
||||
describe('parseAndFormatApiError', () => {
|
||||
const _enterpriseMessage =
|
|
@ -5,15 +5,17 @@
|
|||
*/
|
||||
|
||||
import {
|
||||
AuthType,
|
||||
UserTierId,
|
||||
DEFAULT_GEMINI_FLASH_MODEL,
|
||||
DEFAULT_GEMINI_MODEL,
|
||||
isProQuotaExceededError,
|
||||
isGenericQuotaExceededError,
|
||||
isApiError,
|
||||
isStructuredError,
|
||||
} from '@google/gemini-cli-core';
|
||||
} from './quotaErrorDetection.js';
|
||||
import {
|
||||
DEFAULT_GEMINI_MODEL,
|
||||
DEFAULT_GEMINI_FLASH_MODEL,
|
||||
} from '../config/models.js';
|
||||
import { UserTierId } from '../code_assist/types.js';
|
||||
import { AuthType } from '../core/contentGenerator.js';
|
||||
|
||||
// Free Tier message functions
|
||||
const getRateLimitErrorMessageGoogleFree = (
|
|
@ -4,6 +4,8 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { StructuredError } from '../core/turn.js';
|
||||
|
||||
export interface ApiError {
|
||||
error: {
|
||||
code: number;
|
||||
|
@ -13,11 +15,6 @@ export interface ApiError {
|
|||
};
|
||||
}
|
||||
|
||||
interface StructuredError {
|
||||
message: string;
|
||||
status?: number;
|
||||
}
|
||||
|
||||
export function isApiError(error: unknown): error is ApiError {
|
||||
return (
|
||||
typeof error === 'object' &&
|
||||
|
|
Loading…
Reference in New Issue