feat: add Spotify authentication and sessions
This commit is contained in:
parent
000b435b9a
commit
af3b77a7d0
5 changed files with 294 additions and 0 deletions
31
backend/app/adapters/spotify/errors.py
Normal file
31
backend/app/adapters/spotify/errors.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
"""Typed failures raised by the Spotify adapter."""
|
||||
|
||||
|
||||
class SpotifyError(Exception):
|
||||
"""Base class for Spotify adapter failures."""
|
||||
|
||||
|
||||
class SpotifyAuthenticationError(SpotifyError):
|
||||
"""Spotify rejected authentication or token refresh."""
|
||||
|
||||
|
||||
class SpotifyRateLimitedError(SpotifyError):
|
||||
"""Spotify rate limited a request that could not be retried."""
|
||||
|
||||
def __init__(self, retry_after_seconds: float | None) -> None:
|
||||
"""Record Spotify's requested delay without exposing request data."""
|
||||
super().__init__("Spotify rate limit exceeded")
|
||||
self.retry_after_seconds = retry_after_seconds
|
||||
|
||||
|
||||
class SpotifyUnavailableError(SpotifyError):
|
||||
"""Spotify returned a server-side failure."""
|
||||
|
||||
|
||||
class SpotifyRequestError(SpotifyError):
|
||||
"""Spotify rejected a non-authenticated API request."""
|
||||
|
||||
def __init__(self, status_code: int) -> None:
|
||||
"""Record the response status without exposing response content."""
|
||||
super().__init__(f"Spotify request failed with status {status_code}")
|
||||
self.status_code = status_code
|
||||
Loading…
Add table
Add a link
Reference in a new issue