[GH-ISSUE #681] Hi I want to capture only the error with HTTP:404 No SPOTIFY DEVICE ACTIVE #402

Closed
opened 2026-02-27 23:22:25 +03:00 by kerem · 1 comment
Owner

Originally created by @shreyasajj on GitHub (Apr 24, 2021).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/681

Hi I have some code

try:
  sp.next_track()
catch Exception as e:
  print(e)

I want to only catch the HTTP:404 Player command failed: No Active Devices.
How can I do that?

Originally created by @shreyasajj on GitHub (Apr 24, 2021). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/681 Hi I have some code ``` try: sp.next_track() catch Exception as e: print(e) ``` I want to only catch the HTTP:404 Player command failed: No Active Devices. How can I do that?
kerem 2026-02-27 23:22:25 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@Peter-Schorn commented on GitHub (Apr 24, 2021):

try:
    spotify.next_track()
except spotipy.SpotifyException as error:
    if error.reason != "NO_ACTIVE_DEVICE":
        raise
<!-- gh-comment-id:826109558 --> @Peter-Schorn commented on GitHub (Apr 24, 2021): ```python try: spotify.next_track() except spotipy.SpotifyException as error: if error.reason != "NO_ACTIVE_DEVICE": raise ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#402
No description provided.