fix(vscode-ide-companion): map ENOENT errors to ACP RESOURCE_NOT_FOUND in readTextFile#2291
Conversation
…D in readTextFile - Add error handling in readTextFile to catch and map file system errors - Convert ENOENT errors to RequestError with RESOURCE_NOT_FOUND code - Add unit tests for the error mapping logic Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
📋 Review SummaryThis PR adds proper error handling to the 🔍 General Feedback
🎯 Specific Feedback🟢 Medium
🔵 Low
✅ Highlights
|
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
TLDR
This PR adds error handling to the
readTextFilemethod in the VSCode IDE companion's ACP connection. When a file is not found (ENOENT error), it now returns a proper ACP protocolRESOURCE_NOT_FOUNDerror instead of propagating the raw filesystem error. Unit tests are included.Dive Deeper
The
readTextFileimplementation inacpConnection.tswas not handling filesystem errors properly. When a file didn't exist, the raw ENOENT error would propagate up without being mapped to the ACP protocol's error format.Changes:
mapReadTextFileErrorprivate method that inspects error codes and converts ENOENT to aRequestErrorwithACP_ERROR_CODES.RESOURCE_NOT_FOUNDhandleReadTextFilecall in a try-catch block to intercept and map errorsacpConnection.test.tsto verify ENOENT mapping and passthrough behavior for other error typesThis ensures consistent error responses that conform to the ACP specification.
Reviewer Test Plan
Run the unit tests:
npm run test -- packages/vscode-ide-companion/src/services/acpConnection.test.tsVerify the error mapping logic handles both ENOENT and non-ENOENT cases correctly by reviewing the test assertions.
If testing with a running VSCode extension, attempt to read a non-existent file via ACP and confirm the response contains the
RESOURCE_NOT_FOUNDerror code.Testing Matrix
Linked issues / bugs