Skip to content

Spotify Errors

File with all the errors possible. Every Exception inherits from SpotifyBaseError and therefor implements the get_json method. Which should be used to get api response if a SpotifyAPIError is raised or should be used to get the other general error message

RateLimitExceeded (SpotifyBaseError)

Custom rate limit exceeded exception

Source code in async_spotify/spotify_errors.py
class RateLimitExceeded(SpotifyBaseError):
    """
    Custom rate limit exceeded exception
    """

    def __init__(self, message: dict, retry_after: float):
        self.message: dict = message
        self.retry_after: float = retry_after

SpotifyAPIError (SpotifyBaseError)

Custom api error message This exception gets throws if the spotify api returns an non success return code

Source code in async_spotify/spotify_errors.py
class SpotifyAPIError(SpotifyBaseError):
    """
    Custom api error message
    This exception gets throws if the spotify api returns an *non success* return code
    """

SpotifyBaseError (Exception)

The base Error for all spotify exceptions

Source code in async_spotify/spotify_errors.py
class SpotifyBaseError(Exception):
    """
    The base Error for all spotify exceptions
    """

    def __init__(self, message: dict):
        self.message: dict = message

    def __str__(self):
        return str(self.message)

    def get_json(self) -> Dict[str, Dict[str, str]]:
        """
        Get the the api response which was an error as dict
        {"error":{"status": 400, "message": "The reason"}}
        """
        return self.message

get_json(self)

Get the the api response which was an error as dict {"error":{"status": 400, "message": "The reason"}}

Source code in async_spotify/spotify_errors.py
def get_json(self) -> Dict[str, Dict[str, str]]:
    """
    Get the the api response which was an error as dict
    {"error":{"status": 400, "message": "The reason"}}
    """
    return self.message

SpotifyError (SpotifyBaseError)

Custom error message

Source code in async_spotify/spotify_errors.py
class SpotifyError(SpotifyBaseError):
    """
    Custom error message
    """

TokenExpired (SpotifyBaseError)

Custom token expired message

Source code in async_spotify/spotify_errors.py
class TokenExpired(SpotifyBaseError):
    """
    Custom token expired message
    """

Last update: April 11, 2020