mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
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
This commit is contained in:
parent
7e65f6f6af
commit
b34dc7c8de
8 changed files with 12 additions and 9 deletions
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export type AskApproval = (
|
|||
forceApproval?: boolean,
|
||||
) => Promise<boolean>
|
||||
|
||||
export type HandleError = (action: string, error: Error) => Promise<void>
|
||||
export type HandleError = (action: string, error: Error, title?: string) => Promise<void>
|
||||
|
||||
export type PushToolResult = (content: ToolResponse) => void
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue