Skip to content

Return concise CLI errors for tracker database failures - #408

Open
jay23606 wants to merge 1 commit into
HafidIdrissi:mainfrom
jay23606:pr-go/127-return-concise-cli-errors-for-tracker-da
Open

jay23606 wants to merge 1 commit into
HafidIdrissi:mainfrom
jay23606:pr-go/127-return-concise-cli-errors-for-tracker-da

Conversation

@jay23606

@jay23606 jay23606 commented Dec 6, 2026

Copy link
Copy Markdown

Problem

track.main handled RuntimeError and ValueError, but a database that cannot be opened (for example, a path that is a directory) raised sqlite3.OperationalError and printed an uncaught traceback.

Change

  • Database open failures (sqlite3.Error from ActivityDatabase(...)) are logged as one line and return exit status 1. ActivityDatabase already closes its connection when construction fails.
  • sqlite3.Error raised while tracking is logged as one line and returns 1.
  • OSError is not caught anywhere else, so unrelated OS errors keep their tracebacks.
  • Open failures happen before ActivityTracker.run(), which logs "Tracker started", so a failed open never prints a start message.
  • Regression test: test_database_failure_logs_a_concise_error_and_exits_nonzero now points --database at a temporary directory, so a real SQLite open fails instead of a mock. It asserts exit 1, the one-line error, and that the tracker is never constructed.

Testing

  • .venv/bin/python -m unittest tests.test_track_cli.TrackCliTests.test_database_failure_logs_a_concise_error_and_exits_nonzero: passes on this change.
  • Same test with git show ccbfbc4:track.py > track.py (base track.py, updated test): fails with sqlite3.OperationalError: unable to open database file.
  • .venv/bin/python -m unittest discover: OK (skipped=7).

CI was not run.

Regression test: fails on base twice (/sqlite3.OperationalError: unable to open database file/), passes on fix twice (.venv/bin/python -m unittest tests.test_track_cli.TrackCliTests.test_database_failure_logs_a_concise_error_and_exits_nonzero)

Fixes #127

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.

Return concise CLI errors for tracker database and filesystem failures

1 participant