fix: handle unsupported language errors gracefully in read_file tool (#3359)

Co-authored-by: Eric Wheeler <roo-code@z.ewheeler.org>
This commit is contained in:
KJ7LNW 2025-05-08 19:51:44 -07:00 committed by hannesrudolph
parent 2cf6eb192d
commit a911e78d77

View file

@ -164,7 +164,21 @@ export async function readFileTool(
const res = await Promise.all([
maxReadFileLine > 0 ? readLines(absolutePath, maxReadFileLine - 1, 0) : "",
parseSourceCodeDefinitionsForFile(absolutePath, cline.rooIgnoreController),
(async () => {
try {
return await parseSourceCodeDefinitionsForFile(absolutePath, cline.rooIgnoreController)
} catch (error) {
if (error instanceof Error && error.message.startsWith("Unsupported language:")) {
console.warn(`[read_file] Warning: ${error.message}`)
return undefined
} else {
console.error(
`[read_file] Unhandled error: ${error instanceof Error ? error.message : String(error)}`,
)
return undefined
}
}
})(),
])
content = res[0].length > 0 ? addLineNumbers(res[0]) : ""