Skip to content

Commit 1688bd6

Browse files
KJ7LNWEric Wheeler
andauthored
fix: handle unsupported language errors gracefully in read_file tool (#3359)
Co-authored-by: Eric Wheeler <[email protected]>
1 parent 83bf86f commit 1688bd6

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/core/tools/readFileTool.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,21 @@ export async function readFileTool(
164164

165165
const res = await Promise.all([
166166
maxReadFileLine > 0 ? readLines(absolutePath, maxReadFileLine - 1, 0) : "",
167-
parseSourceCodeDefinitionsForFile(absolutePath, cline.rooIgnoreController),
167+
(async () => {
168+
try {
169+
return await parseSourceCodeDefinitionsForFile(absolutePath, cline.rooIgnoreController)
170+
} catch (error) {
171+
if (error instanceof Error && error.message.startsWith("Unsupported language:")) {
172+
console.warn(`[read_file] Warning: ${error.message}`)
173+
return undefined
174+
} else {
175+
console.error(
176+
`[read_file] Unhandled error: ${error instanceof Error ? error.message : String(error)}`,
177+
)
178+
return undefined
179+
}
180+
}
181+
})(),
168182
])
169183

170184
content = res[0].length > 0 ? addLineNumbers(res[0]) : ""

0 commit comments

Comments
 (0)