Skip to content

fix: clean error when report --out parent dir is missing - #19

Merged
royalpinto007 merged 1 commit into
AgentPostmortem:mainfrom
sharadvc:fix/report-out-missing-parent-dir
Sep 16, 2026
Merged

royalpinto007 merged 1 commit into
AgentPostmortem:mainfrom
sharadvc:fix/report-out-missing-parent-dir

Conversation

@sharadvc

Copy link
Copy Markdown
Contributor

What

ctxlens report --out missing/dir/r.html crashed with an unhandled FileNotFoundError traceback because out.write_text(...) sat outside _load's try/except.

Change

Wrap the report write in the same OSError handling _load already uses: print a clean error: line to stderr and exit with code 1. Mirrors the accepted error path used everywhere else in the CLI.

Tests

Added a failing test first (per the issue's acceptance criteria): report with --out pointing into a missing parent directory expects exit 1, a clean error: line, and no traceback. Full suite: 62 passed. ruff check clean.

Related

Closes #13

Wrap the report write in the same OSError handling as _load so a missing
parent directory prints a clean 'error:' line and exits 1 instead of
escaping an unhandled FileNotFoundError traceback.

Closes AgentPostmortem#13
@royalpinto007
royalpinto007 merged commit fb5d5ed into AgentPostmortem:main Sep 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

report --out to a missing parent dir crashes with traceback

2 participants