fix(cli): handle writeFileSync errors in export --out with a clean message#70
Open
Open2Loop wants to merge 1 commit into
Open
fix(cli): handle writeFileSync errors in export --out with a clean message#70Open2Loop wants to merge 1 commit into
Open2Loop wants to merge 1 commit into
Conversation
When `--out` points at a missing directory or an unwritable path, `writeFileSync` throws `ENOENT`/`EACCES`. Because `reportError` in `main.ts` only recognises structured error types, the raw Node stack trace was printed to the user instead of a friendly message. Wrap the `writeFileSync` call in a try/catch that emits a single-line `agentctx export: <message>` error on stderr and returns exit code 1, matching how other filesystem failures are reported elsewhere in the CLI. Fixes agentctxhq#69 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
@Open2Loop please add the tests as required by the issue description. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #69.
agentctx export --out <path>calledwriteFileSyncwith no error handling. When the target directory doesn't exist (or the path isn't writable), the raw Node stack trace was printed instead of a clean error message, becausereportErrorinmain.tsonly recognises structured error types.Fix: wrap
writeFileSyncin atry/catchthat emits a single-lineagentctx export: <message>error on stderr and returns exit code1— matching how other filesystem failures are handled in the CLI.Change
🤖 Generated with Claude Code