mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 00:25:54 +03:00
[GH-ISSUE #1160] All Spotipy exceptions should inherit from SpotifyException #684
Labels
No labels
api-bug
bug
dependencies
documentation
duplicate
enhancement
external-ide
headless-mode
implicit-grant-flow
invalid
missing-endpoint
pr-welcome
private-api
pull-request
question
spotipy3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotipy#684
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @vitorbaptista on GitHub (Oct 5, 2024).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1160
Is your feature request related to a problem? Please describe.
I'd like to be able to catch any exceptions raised by Spotipy. I thought this was what
spotipy.client.SpotifyExceptionwas for, butspotipy.oauth2.SpotifyOauthErrorinherits from Python's baseException.Describe the solution you'd like
If I catch
spotipy.client.SpotifyExceptionI should catch all exceptions raised by Spotipy.Describe alternatives you've considered
Explicitly using
except (spotipy.client.SpotifyException, spotipy.oauth2.SpotifyOauthError) as e. This works, but feels a bit too coupled.@dieser-niko commented on GitHub (Oct 6, 2024):
@stephanebruckert any objections? Otherwise I would just start working on a PR.
I don't see any reason why it should stay this way.
Currently there are 3 exception classes:
exceptions.SpotifyException/client.SpotifyExceptionoauth2.SpotifyOauthErroroauth2.SpotifyStateErrorAs a change, I would suggest adding a new exception called
SpotifyBaseExceptionwith no specific attributes, as theSpotifyOauthErrordoesn't share any attributes withSpotifyException.Also while we're at it, I would move the errors from
oauth2.pyto the already existingexceptions.pyfile, because they don't need any imports.@dieser-niko commented on GitHub (Oct 6, 2024):
I've created a PR, you can try it out by adding this to your
requirements.txtfile:I've implemented it like I've described in my last comment.