Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/core/src/ide/ide-installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ class VsCodeInstaller implements IdeInstaller {
['--install-extension', vsixPath, '--force'],
{
stdio: 'pipe',
shell: os.platform() === 'win32' && commandPath.endsWith('.cmd')
}
shell: os.platform() === 'win32' && commandPath.endsWith('.cmd'),
},
);
return {
success: true,
Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/tools/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { ToolErrorType } from './tool-error.js';
import { Type } from '@google/genai';
import { SchemaValidator } from '../utils/schemaValidator.js';
import { makeRelative, shortenPath } from '../utils/paths.js';
import { isNodeError } from '../utils/errors.js';
import { getErrorMessage, isNodeError } from '../utils/errors.js';
import { Config, ApprovalMode } from '../config/config.js';
import { ensureCorrectEdit } from '../utils/editCorrector.js';
import { DEFAULT_DIFF_OPTIONS, getDiffStat } from './diffOptions.js';
Expand Down Expand Up @@ -229,8 +229,8 @@ class EditToolInvocation implements ToolInvocation<EditToolParams, ToolResult> {
let editData: CalculatedEdit;
try {
editData = await this.calculateEdit(this.params, abortSignal);
} catch (error) {
const errorMsg = error instanceof Error ? error.message : String(error);
} catch (error: unknown) {
const errorMsg = getErrorMessage(error);
console.log(`Error preparing edit: ${errorMsg}`);
return false;
}
Expand Down Expand Up @@ -316,8 +316,8 @@ class EditToolInvocation implements ToolInvocation<EditToolParams, ToolResult> {
let editData: CalculatedEdit;
try {
editData = await this.calculateEdit(this.params, signal);
} catch (error) {
const errorMsg = error instanceof Error ? error.message : String(error);
} catch (error: unknown) {
const errorMsg = getErrorMessage(error);
return {
llmContent: `Error preparing edit: ${errorMsg}`,
returnDisplay: `Error preparing edit: ${errorMsg}`,
Expand Down Expand Up @@ -390,8 +390,8 @@ class EditToolInvocation implements ToolInvocation<EditToolParams, ToolResult> {
llmContent: llmSuccessMessageParts.join(' '),
returnDisplay: displayResult,
};
} catch (error) {
const errorMsg = error instanceof Error ? error.message : String(error);
} catch (error: unknown) {
const errorMsg = getErrorMessage(error);
return {
llmContent: `Error executing edit: ${errorMsg}`,
returnDisplay: `Error writing file: ${errorMsg}`,
Expand Down
9 changes: 8 additions & 1 deletion packages/core/src/utils/errors.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

import { describe, it, expect } from 'vitest';

import {
toFriendlyError,
BadRequestError,
UnauthorizedError,
ForbiddenError,
} from './errors';
} from './errors.js';

describe('toFriendlyError', () => {
it('should return the original error if it is not an object', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/utils/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ describe('fetchWithTimeout', () => {
it('should throw FetchError with ETIMEDOUT code when request times out', async () => {
// Mock fetch to simulate timeout behavior
(fetch as unknown as ReturnType<typeof vi.fn>).mockImplementation(
(url: string, options: { signal: AbortSignal }) => new Promise((_, reject) => {
(url: string, options: { signal: AbortSignal }) =>
new Promise((_, reject) => {
if (options.signal.aborted) {
const error = new Error('The operation was aborted');
(error as any).code = 'ABORT_ERR';
Expand Down