Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves error debugging by preserving the original filesystem error when a file is not found. When an ENOENT error occurs during file opening, the new code wraps it in a "File missing" error with the original error stored in the cause property, making it easier to debug file access issues.
Changes:
- Added error cause chaining to preserve the original ENOENT error when throwing "File missing" errors
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| throw err; | ||
| } | ||
| throw new Error("File missing"); | ||
| throw new Error("File missing", { cause: err }); |
There was a problem hiding this comment.
The test coverage for this change is missing. The existing test at line 385-392 in test/index.test.js only verifies that the error message is "File missing", but doesn't check that the cause property is set correctly with the original ENOENT error. Since the package.json specifies 100% coverage requirements and the PR description mentions "TODO: add unit test", a test should be added to verify the cause property contains the original filesystem error.
a782cb5 to
6690802
Compare
Assists in debugging.
TODO: add unit test
Checklist
npm test