From b34dc7c8de456f95acb59c24f74015a25dc9a60f Mon Sep 17 00:00:00 2001 From: Roo Code Date: Mon, 8 Sep 2025 21:41:09 +0000 Subject: [PATCH] feat: update handleError to accept optional title parameter - Updated HandleError type to accept optional title parameter - Modified handleError function in presentAssistantMessage to pass title to say method - Added custom error titles to various tool error handlers - Updated tests to expect the new third parameter --- src/core/assistant-message/presentAssistantMessage.ts | 5 ++++- src/core/tools/__tests__/writeToFileTool.spec.ts | 4 ++-- src/core/tools/applyDiffTool.ts | 2 +- src/core/tools/insertContentTool.ts | 2 +- src/core/tools/multiApplyDiffTool.ts | 2 +- src/core/tools/searchAndReplaceTool.ts | 2 +- src/core/tools/writeToFileTool.ts | 2 +- src/shared/tools.ts | 2 +- 8 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/core/assistant-message/presentAssistantMessage.ts b/src/core/assistant-message/presentAssistantMessage.ts index 689675999f..d4fee5d0a1 100644 --- a/src/core/assistant-message/presentAssistantMessage.ts +++ b/src/core/assistant-message/presentAssistantMessage.ts @@ -317,12 +317,15 @@ export async function presentAssistantMessage(cline: Task) { return await askApproval("tool", toolMessage) } - const handleError = async (action: string, error: Error) => { + const handleError = async (action: string, error: Error, title?: string) => { const errorString = `Error ${action}: ${JSON.stringify(serializeError(error))}` await cline.say( "error", `Error ${action}:\n${error.message ?? JSON.stringify(serializeError(error), null, 2)}`, + undefined, + undefined, + title ? { title } : undefined, ) pushToolResult(formatResponse.toolError(errorString)) diff --git a/src/core/tools/__tests__/writeToFileTool.spec.ts b/src/core/tools/__tests__/writeToFileTool.spec.ts index 78e60cbaa5..25bfbcb383 100644 --- a/src/core/tools/__tests__/writeToFileTool.spec.ts +++ b/src/core/tools/__tests__/writeToFileTool.spec.ts @@ -403,7 +403,7 @@ describe("writeToFileTool", () => { await executeWriteFileTool({}) - expect(mockHandleError).toHaveBeenCalledWith("writing file", expect.any(Error)) + expect(mockHandleError).toHaveBeenCalledWith("writing file", expect.any(Error), "Write File Error") expect(mockCline.diffViewProvider.reset).toHaveBeenCalled() }) @@ -412,7 +412,7 @@ describe("writeToFileTool", () => { await executeWriteFileTool({}, { isPartial: true }) - expect(mockHandleError).toHaveBeenCalledWith("writing file", expect.any(Error)) + expect(mockHandleError).toHaveBeenCalledWith("writing file", expect.any(Error), "Write File Error") expect(mockCline.diffViewProvider.reset).toHaveBeenCalled() }) }) diff --git a/src/core/tools/applyDiffTool.ts b/src/core/tools/applyDiffTool.ts index 0c7dde79f4..51383b75a7 100644 --- a/src/core/tools/applyDiffTool.ts +++ b/src/core/tools/applyDiffTool.ts @@ -251,7 +251,7 @@ export async function applyDiffToolLegacy( return } } catch (error) { - await handleError("applying diff", error) + await handleError("applying diff", error, "Apply Diff Error") await cline.diffViewProvider.reset() return } diff --git a/src/core/tools/insertContentTool.ts b/src/core/tools/insertContentTool.ts index e3ad736011..ef0917badb 100644 --- a/src/core/tools/insertContentTool.ts +++ b/src/core/tools/insertContentTool.ts @@ -191,7 +191,7 @@ export async function insertContentTool( await cline.diffViewProvider.reset() } catch (error) { - handleError("insert content", error) + handleError("insert content", error, "Insert Content Error") await cline.diffViewProvider.reset() } } diff --git a/src/core/tools/multiApplyDiffTool.ts b/src/core/tools/multiApplyDiffTool.ts index 50695b1da7..77a2a8057f 100644 --- a/src/core/tools/multiApplyDiffTool.ts +++ b/src/core/tools/multiApplyDiffTool.ts @@ -677,7 +677,7 @@ ${errorDetails ? `\nTechnical details:\n${errorDetails}\n` : ""} pushToolResult(results.join("\n\n") + singleBlockNotice) return } catch (error) { - await handleError("applying diff", error) + await handleError("applying diff", error, "Apply Diff Error") await cline.diffViewProvider.reset() return } diff --git a/src/core/tools/searchAndReplaceTool.ts b/src/core/tools/searchAndReplaceTool.ts index 1d017c8c1e..5816fd7da2 100644 --- a/src/core/tools/searchAndReplaceTool.ts +++ b/src/core/tools/searchAndReplaceTool.ts @@ -268,7 +268,7 @@ export async function searchAndReplaceTool( cline.recordToolUsage("search_and_replace") await cline.diffViewProvider.reset() } catch (error) { - handleError("search and replace", error) + handleError("search and replace", error, "Search and Replace Error") await cline.diffViewProvider.reset() } } diff --git a/src/core/tools/writeToFileTool.ts b/src/core/tools/writeToFileTool.ts index e82eab92bc..4342a55229 100644 --- a/src/core/tools/writeToFileTool.ts +++ b/src/core/tools/writeToFileTool.ts @@ -311,7 +311,7 @@ export async function writeToFileTool( return } } catch (error) { - await handleError("writing file", error) + await handleError("writing file", error, "Write File Error") await cline.diffViewProvider.reset() return } diff --git a/src/shared/tools.ts b/src/shared/tools.ts index 608b50752e..fedc300e77 100644 --- a/src/shared/tools.ts +++ b/src/shared/tools.ts @@ -11,7 +11,7 @@ export type AskApproval = ( forceApproval?: boolean, ) => Promise -export type HandleError = (action: string, error: Error) => Promise +export type HandleError = (action: string, error: Error, title?: string) => Promise export type PushToolResult = (content: ToolResponse) => void