31 lines
1 KiB
Python
31 lines
1 KiB
Python
"""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
|