-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Handle errors more gracefully when reading custom instructions from files #1093
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same diff is being generated if I run npm run install:all on main. Looks like we missed it here #1051 maybe?
| if (content.trim()) { | ||
| modeRuleContent = content.trim() | ||
| } | ||
| } catch (err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, consider using a shared helper for error checks here as well to improve maintainability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
src/core/prompts/sections/__tests__/custom-instructions.test.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Description
Fix the reported issue where the extension breaks if it is a directory
#1092 (comment)
Type of change
How Has This Been Tested?
Added unit tests
Checklist:
Additional context
Related Issues
Reviewers
Important
Introduces
safeReadFileto handle file reading errors gracefully incustom-instructions.ts, with tests added incustom-instructions.test.ts.safeReadFileincustom-instructions.tsto handleENOENTandEISDIRerrors gracefully, returning an empty string instead of throwing.loadRuleFilesandaddCustomInstructionsincustom-instructions.tsto usesafeReadFilefor reading files.custom-instructions.test.tsto verifysafeReadFilebehavior forENOENT,EISDIR, and unexpected errors.loadRuleFilesandaddCustomInstructionsfor correct handling of directories and missing files.This description was created by
for 053671e. It will automatically update as commits are pushed.