diff options
| author | Akhil Appana <[email protected]> | 2025-08-08 04:33:42 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-08 11:33:42 +0000 |
| commit | f5e0f16157da6a0b0dbae3b4ebf920fdee81c461 (patch) | |
| tree | e8f91ee92d41a5ac7280b2bad7e8cba103bc1ca7 /packages/core/src/utils/fileUtils.ts | |
| parent | 5ab184fcaf40d4e7dec9ba6a0526cac39b602ee2 (diff) | |
fix: properly report tool errors in telemetry (#5688)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Diffstat (limited to 'packages/core/src/utils/fileUtils.ts')
| -rw-r--r-- | packages/core/src/utils/fileUtils.ts | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/packages/core/src/utils/fileUtils.ts b/packages/core/src/utils/fileUtils.ts index 30ab69c6..92186e4f 100644 --- a/packages/core/src/utils/fileUtils.ts +++ b/packages/core/src/utils/fileUtils.ts @@ -195,10 +195,18 @@ export async function detectFileType( return 'text'; } +export enum FileErrorType { + FILE_NOT_FOUND = 'FILE_NOT_FOUND', + IS_DIRECTORY = 'IS_DIRECTORY', + FILE_TOO_LARGE = 'FILE_TOO_LARGE', + READ_ERROR = 'READ_ERROR', +} + export interface ProcessedFileReadResult { llmContent: PartUnion; // string for text, Part for image/pdf/unreadable binary returnDisplay: string; error?: string; // Optional error message for the LLM if file processing failed + errorType?: FileErrorType; // Structured error type using enum isTruncated?: boolean; // For text files, indicates if content was truncated originalLineCount?: number; // For text files linesShown?: [number, number]; // For text files [startLine, endLine] (1-based for display) @@ -225,6 +233,7 @@ export async function processSingleFileContent( llmContent: '', returnDisplay: 'File not found.', error: `File not found: ${filePath}`, + errorType: FileErrorType.FILE_NOT_FOUND, }; } const stats = await fs.promises.stat(filePath); @@ -233,6 +242,7 @@ export async function processSingleFileContent( llmContent: '', returnDisplay: 'Path is a directory.', error: `Path is a directory, not a file: ${filePath}`, + errorType: FileErrorType.IS_DIRECTORY, }; } |
