Raise Spotify exception if no active device found #48486
Merged
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.
Breaking change
Proposed change
Currently we "silently" fail in the sense we add a log entry, but the user does not currently understand why nothing is happening when clicking in the frontend on the play button in a Spotify media card, when no device is active.
Now we raise an exception which will result in a frontend toast.
I handled it now through the
spotify_exception_handler
which however also results in a callstack trace in the log (not really sure why). As a test I had the exception raising initially implemented directly in themedia_play
andplay_media
method, but that felt less clean from a coding perspective.This is how it looks in the fronted => I would have loved to only have the actual user message ("No active playback device found") as that would be cleaner and clearer.
Type of change
Example entry for
configuration.yaml
:# Example configuration.yaml
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: