♻️ Replace SystemExit with structured errors in admin CLI#252
Open
Gudsfile wants to merge 4 commits into
Open
Conversation
483d022 to
1ad5b63
Compare
0b399fb to
23f32c6
Compare
1ad5b63 to
82f5b2d
Compare
Base automatically changed from
refactor/phase-2b-settings-sonos-page-builder-tests
to
main
May 7, 2026 16:55
ec69ef0 to
6d1af7b
Compare
6d1af7b to
232695c
Compare
…) raised by _raise_optional_extra_error
Move MissingOptionalDependencyError from jukebox/admin/errors.py to jukebox/shared/errors.py so all adapters (pn532, api, ui, admin) can raise a single structured error type Absorb optional_extra_dependency_message into the class as an install_hint property and delete dependency_messages.py.
232695c to
37db220
Compare
msgerbush
approved these changes
May 13, 2026
Collaborator
msgerbush
left a comment
There was a problem hiding this comment.
One small issue, otherwise looks good to me!
| try: | ||
| from pn532 import PN532_SPI | ||
| except ModuleNotFoundError as err: | ||
| raise ModuleNotFoundError(optional_extra_dependency_message("The `pn532` reader", "pn532", "jukebox ...")) from err |
Collaborator
There was a problem hiding this comment.
I think this is going to cause an issue in pn532_command_handlers.py, since we were specifically handling ModuleNotFoundError
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
Improve CLI error handling by replacing SystemExit-based flows with explicit Exception or Typer-native mechanisms.
MissingOptionalDependencyErrorto replaceSystemExit(str)previously raised by_raise_optional_extra_errorand propagated through the CLI adapter._exit_on_command_validation_errorwith a new_exit_errorhelper usingtyper.echoandtyper.Exitinstead ofSystemExit(str)._exit_successto mirror_exit_errorfor consistent success exits.optional_extra_dependency_messageintoMissingOptionalDependencyErroras aninstall_hintproperty and align the pn532, API and UI adapters to use it.Test plan
uv syncto remove extrauv run --extra ui pytestuv run jukebox-admin api-> concise install hintuv run jukebox-admin --verbose api-> install hintuv run --extra api jukebox-admin api-> worksuv run jukebox --reader pn532-> stack trace with the install hint (improving the case display is not within the scope of this PR)Out of scope
Does not suppress the
SystemExitof thejukeboxCLI (it's done in #254).