Skip to content

Commit d5c66f6

Browse files
daniel-lxsroomote
authored andcommitted
fix: improve file not found error detection
- Check for ENOENT in error code, message content, and common error patterns - This ensures the file_not_found_error message is properly emitted - The UI component will now be displayed instead of raw error text
1 parent 1f322e0 commit d5c66f6

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/core/tools/readFileTool.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,14 @@ export async function readFileTool(
613613
let errorMsg = error instanceof Error ? error.message : String(error)
614614

615615
// Check if this is a file not found error
616-
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
616+
const isFileNotFound =
617+
error instanceof Error &&
618+
(("code" in error && error.code === "ENOENT") ||
619+
errorMsg.includes("ENOENT") ||
620+
errorMsg.includes("no such file or directory") ||
621+
errorMsg.includes("File not found"))
622+
623+
if (isFileNotFound) {
617624
// Emit a proper typed message for file not found errors
618625
await cline.say(
619626
"file_not_found_error",
@@ -716,7 +723,14 @@ export async function readFileTool(
716723
let errorMsg = error instanceof Error ? error.message : String(error)
717724

718725
// Check if this is a file not found error
719-
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
726+
const isFileNotFound =
727+
error instanceof Error &&
728+
(("code" in error && error.code === "ENOENT") ||
729+
errorMsg.includes("ENOENT") ||
730+
errorMsg.includes("no such file or directory") ||
731+
errorMsg.includes("File not found"))
732+
733+
if (isFileNotFound) {
720734
// Emit a proper typed message for file not found errors
721735
await cline.say(
722736
"file_not_found_error",

0 commit comments

Comments
 (0)