Error Handling


Enumerations

enum  sp_error {
  SP_ERROR_OK = 0,
  SP_ERROR_BAD_API_VERSION = 1,
  SP_ERROR_API_INITIALIZATION_FAILED = 2,
  SP_ERROR_TRACK_NOT_PLAYABLE = 3,
  SP_ERROR_RESOURCE_NOT_LOADED = 4,
  SP_ERROR_BAD_APPLICATION_KEY = 5,
  SP_ERROR_BAD_USERNAME_OR_PASSWORD = 6,
  SP_ERROR_USER_BANNED = 7,
  SP_ERROR_UNABLE_TO_CONTACT_SERVER = 8,
  SP_ERROR_CLIENT_TOO_OLD = 9,
  SP_ERROR_OTHER_PERMAMENT = 10,
  SP_ERROR_BAD_USER_AGENT = 11,
  SP_ERROR_MISSING_CALLBACK = 12,
  SP_ERROR_INVALID_INDATA = 13,
  SP_ERROR_INDEX_OUT_OF_RANGE = 14,
  SP_ERROR_USER_NEEDS_PREMIUM = 15,
  SP_ERROR_OTHER_TRANSIENT = 16,
  SP_ERROR_IS_LOADING = 17
}

Functions

const char * sp_error_message (sp_error error)

Detailed Description

All functions in libspotify use the same set of error codes. Most of them return an error code, and let the result of the operation be stored in an out-parameter.

Enumeration Type Documentation

enum sp_error

Error codes returned by various functions

Enumerator:
SP_ERROR_OK  No errors encountered.
SP_ERROR_BAD_API_VERSION  The library version targeted does not match the one you claim you support.
SP_ERROR_API_INITIALIZATION_FAILED  Initialization of library failed - are cache locations etc. valid?
SP_ERROR_TRACK_NOT_PLAYABLE  The track specified for playing cannot be played.
SP_ERROR_RESOURCE_NOT_LOADED  One or several of the supplied resources is not yet loaded.
SP_ERROR_BAD_APPLICATION_KEY  The application key is invalid.
SP_ERROR_BAD_USERNAME_OR_PASSWORD  Login failed because of bad username and/or password.
SP_ERROR_USER_BANNED  The specified username is banned.
SP_ERROR_UNABLE_TO_CONTACT_SERVER  Cannot connect to the Spotify backend system.
SP_ERROR_CLIENT_TOO_OLD  Client is too old, library will need to be updated.
SP_ERROR_OTHER_PERMAMENT  Some other error occured, and it is permanent (e.g. trying to relogin will not help).
SP_ERROR_BAD_USER_AGENT  The user agent string is invalid or too long.
SP_ERROR_MISSING_CALLBACK  No valid callback registered to handle events.
SP_ERROR_INVALID_INDATA  Input data was either missing or invalid.
SP_ERROR_INDEX_OUT_OF_RANGE  Index out of range.
SP_ERROR_USER_NEEDS_PREMIUM  The specified user needs a premium account.
SP_ERROR_OTHER_TRANSIENT  A transient error occured.
SP_ERROR_IS_LOADING  The resource is currently loading.


Function Documentation

const char* sp_error_message ( sp_error  error  ) 

Convert a numeric libspotify error code to a text string

Here is a snippet from session_ready.c:

    sp_error error = sp_session_logout(session);

    if (SP_ERROR_OK != error) {
        fprintf(stderr, "failed to log out from Spotify: %s\n",
                        sp_error_message(error));
        g_exit_code = 5;
        return;
    }

Parameters:
[in] error The error code to lookup
Examples:
browse.c, jukebox.c, link.c, search.c, session.c, session_ready.c, and track.c.


Generated on Tue Apr 7 15:21:55 2009.
Copyright © 2006–2009 Spotify Ltd