Error handling

exception spotify.Error[source]

A Spotify error.

This is the superclass of all custom exceptions raised by pyspotify.

classmethod maybe_raise(error_type, ignores=None)[source]

Raise an LibError unless the error_type is ErrorType.OK or in the ignores list of error types.

Internal method.

class spotify.ErrorType[source]
API_INITIALIZATION_FAILED = <ErrorType.API_INITIALIZATION_FAILED: 2>
APPLICATION_BANNED = <ErrorType.APPLICATION_BANNED: 27>
BAD_API_VERSION = <ErrorType.BAD_API_VERSION: 1>
BAD_APPLICATION_KEY = <ErrorType.BAD_APPLICATION_KEY: 5>
BAD_USERNAME_OR_PASSWORD = <ErrorType.BAD_USERNAME_OR_PASSWORD: 6>
BAD_USER_AGENT = <ErrorType.BAD_USER_AGENT: 11>
CANT_OPEN_TRACE_FILE = <ErrorType.CANT_OPEN_TRACE_FILE: 26>
CLIENT_TOO_OLD = <ErrorType.CLIENT_TOO_OLD: 9>
INBOX_IS_FULL = <ErrorType.INBOX_IS_FULL: 20>
INDEX_OUT_OF_RANGE = <ErrorType.INDEX_OUT_OF_RANGE: 14>
INVALID_ARGUMENT = <ErrorType.INVALID_ARGUMENT: 40>
INVALID_DEVICE_ID = <ErrorType.INVALID_DEVICE_ID: 25>
INVALID_INDATA = <ErrorType.INVALID_INDATA: 13>
IS_LOADING = <ErrorType.IS_LOADING: 17>
LASTFM_AUTH_ERROR = <ErrorType.LASTFM_AUTH_ERROR: 39>
MISSING_CALLBACK = <ErrorType.MISSING_CALLBACK: 12>
NETWORK_DISABLED = <ErrorType.NETWORK_DISABLED: 24>
NO_CACHE = <ErrorType.NO_CACHE: 21>
NO_CREDENTIALS = <ErrorType.NO_CREDENTIALS: 23>
NO_STREAM_AVAILABLE = <ErrorType.NO_STREAM_AVAILABLE: 18>
NO_SUCH_USER = <ErrorType.NO_SUCH_USER: 22>
OFFLINE_DISK_CACHE = <ErrorType.OFFLINE_DISK_CACHE: 32>
OFFLINE_EXPIRED = <ErrorType.OFFLINE_EXPIRED: 33>
OFFLINE_LICENSE_ERROR = <ErrorType.OFFLINE_LICENSE_ERROR: 36>
OFFLINE_LICENSE_LOST = <ErrorType.OFFLINE_LICENSE_LOST: 35>
OFFLINE_NOT_ALLOWED = <ErrorType.OFFLINE_NOT_ALLOWED: 34>
OFFLINE_TOO_MANY_TRACKS = <ErrorType.OFFLINE_TOO_MANY_TRACKS: 31>
OK = <ErrorType.OK: 0>
OTHER_PERMANENT = <ErrorType.OTHER_PERMANENT: 10>
OTHER_TRANSIENT = <ErrorType.OTHER_TRANSIENT: 16>
PERMISSION_DENIED = <ErrorType.PERMISSION_DENIED: 19>
SYSTEM_FAILURE = <ErrorType.SYSTEM_FAILURE: 41>
TRACK_NOT_PLAYABLE = <ErrorType.TRACK_NOT_PLAYABLE: 3>
UNABLE_TO_CONTACT_SERVER = <ErrorType.UNABLE_TO_CONTACT_SERVER: 8>
USER_BANNED = <ErrorType.USER_BANNED: 7>
USER_NEEDS_PREMIUM = <ErrorType.USER_NEEDS_PREMIUM: 15>
exception spotify.LibError(error_type)[source]

A libspotify error.

Where many libspotify functions return error codes that must be checked after each and every function call, pyspotify raises the LibError exception instead. This helps you to not accidentally swallow and hide errors when using pyspotify.

error_type = None

The ErrorType of the error.

exception spotify.Timeout(timeout)[source]

Exception raised by an operation not completing within the given timeout.