feat(core): Annotate remaining error paths in tools with type. (#6699)

This commit is contained in:
joshualitt
2025-08-21 14:40:18 -07:00
committed by GitHub
parent 299bf58309
commit ec41b8db8e
19 changed files with 348 additions and 48 deletions
+4
View File
@@ -23,6 +23,7 @@ import { LSTool } from './ls.js';
import { Config } from '../config/config.js';
import { WorkspaceContext } from '../utils/workspaceContext.js';
import { FileDiscoveryService } from '../services/fileDiscoveryService.js';
import { ToolErrorType } from './tool-error.js';
describe('LSTool', () => {
let lsTool: LSTool;
@@ -288,6 +289,7 @@ describe('LSTool', () => {
expect(result.llmContent).toContain('Path is not a directory');
expect(result.returnDisplay).toBe('Error: Path is not a directory.');
expect(result.error?.type).toBe(ToolErrorType.PATH_IS_NOT_A_DIRECTORY);
});
it('should handle non-existent paths', async () => {
@@ -302,6 +304,7 @@ describe('LSTool', () => {
expect(result.llmContent).toContain('Error listing directory');
expect(result.returnDisplay).toBe('Error: Failed to list directory.');
expect(result.error?.type).toBe(ToolErrorType.LS_EXECUTION_ERROR);
});
it('should sort directories first, then files alphabetically', async () => {
@@ -357,6 +360,7 @@ describe('LSTool', () => {
expect(result.llmContent).toContain('Error listing directory');
expect(result.llmContent).toContain('permission denied');
expect(result.returnDisplay).toBe('Error: Failed to list directory.');
expect(result.error?.type).toBe(ToolErrorType.LS_EXECUTION_ERROR);
});
it('should throw for invalid params at build time', async () => {