cli: properly handle exceptions
Metadata
Current evaluation
Merged in commit be340e4f7, adding a global sys.excepthook for consistent CLI exception handling across store and future commands.
Resolution: closed resolved
Reason: PR #1436 was approved and merged as the simpler alternative to #1429. Commit be340e4f7 added global exception handling and swept CLI exceptions.
Evaluated by: mr-cal-bot
No scores available.
Issue body
This PR is an alternative to #1429. Instead of using click-specific decorators for every command, it simply installs a `sys.excepthandler` to deal properly with exceptions.
Advantages over #1429:
- Simpler
- Covers the store CLI with no additional work
- Covers future CLI additions automatically, nothing special needed
Disadvantages compared to #1429:
- Can no longer unit test CLI exit codes since the CLI is run within the same python process, the test catches the exception, and `excepthook` is never called. Integrations tests are needed instead.
- Global behavior can cause unexpected things to happen (i.e. the simple fact that some exceptions are masked by a global handler may be unexpected a year down the road when we add a new command)
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged in commit be340e4f7, adding a global sys.excepthook for consistent CLI exception handling across store and future commands. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #1436 (commit be340e4f7) replaced per-command click exception decorators with a global sys.excepthook in the CLI, superseding #1429; store/future commands get handling for free. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #1436 (commit be340e4f7) added a global sys.excepthook for CLI exceptions, superseding #1429 and automatically covering store and future commands. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged #1436 introduced a global sys.excepthook-based CLI exception handler, replacing #1429's per-command decorators and covering existing and future commands. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged a global exception handler for CLI errors, superseding PR #1429. Replaced per-command decorators to simplify maintenance and auto-coverage. Fixed exit_code property test failures before merge. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged. Implements a global sys.excepthandler for CLI exception handling, superseding PR #1429. Includes an exception sweep, shifts exit code verification to integration tests, and addresses review feedback on property naming and commit structure. |
Update history
No update history recorded yet.
Related work
-
Related To:
canonical/snapcraft#1429
(confidence 99%)
Alternative Click-decorator approach replaced by the merged implementation in #1436.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1429 cli: properly handle exceptions in lifecycle | snapcraft | closed | Closed in favor of #1436, which implemented global CLI exception handling and merged as commit be340e4f7. | |
| #1495 cli: don't raise from excepthook | snapcraft | merged | Merged PR #1495 in commit f09ea712c, replacing exceptions raised from the CLI excepthook with direct traceback printing and an appropriate exit. |