feat(errors): Make errors more informative (#7133)

This commit is contained in:
Lee James 2025-08-26 19:22:05 -04:00 committed by GitHub
parent 6fb01ddcc4
commit 3e74ff71b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 133 additions and 11 deletions

View file

@ -48,6 +48,7 @@ vi.mock('@google/gemini-cli-core', async () => {
const mockToolRegistry = {
getTool: vi.fn(),
getAllToolNames: vi.fn(() => ['mockTool', 'anotherTool']),
};
const mockConfig = {
@ -427,11 +428,17 @@ describe('useReactToolScheduler', () => {
request,
response: expect.objectContaining({
error: expect.objectContaining({
message: 'Tool "nonexistentTool" not found in registry.',
message: expect.stringMatching(
/Tool "nonexistentTool" not found in registry/,
),
}),
}),
}),
]);
const errorMessage = onComplete.mock.calls[0][0][0].response.error.message;
expect(errorMessage).toContain('Did you mean one of:');
expect(errorMessage).toContain('"mockTool"');
expect(errorMessage).toContain('"anotherTool"');
expect(result.current[0]).toEqual([]);
});