Exception: Spotify::APIError Abstract
- Extended by:
- FFI::DataConverter
- Defined in:
- lib/spotify/error.rb
Overview
Generic error class, extended by all libspotify errors.
Direct Known Subclasses
APIInitializationFailedError, ApplicationBannedError, BadAPIVersionError, BadApplicationKeyError, BadUserAgentError, BadUsernameOrPasswordError, CantOpenTraceFileError, ClientTooOldError, InboxIsFullError, IndexOutOfRangeError, InvalidArgumentError, InvalidDeviceIdError, InvalidIndataError, IsLoadingError, LastfmAuthError, MissingCallbackError, NetworkDisabledError, NoCacheError, NoCredentialsError, NoStreamAvailableError, NoSuchUserError, OfflineDiskCacheError, OfflineExpiredError, OfflineLicenseError, OfflineLicenseLostError, OfflineNotAllowedError, OfflineTooManyTracksError, OtherPermanentError, OtherTransientError, PermissionDeniedError, SystemFailureError, TrackNotPlayableError, UnableToContactServerError, UserBannedError, UserNeedsPremiumError
Constant Summary collapse
- @@code_to_class =
{ 0 => nil }
Class Attribute Summary collapse
-
.to_i ⇒ Integer
readonly
Error code.
Class Method Summary collapse
-
.from_native(error, context) ⇒ Error?
Returns an error if applicable.
-
.to_native(error, context) ⇒ Symbol
From an error, retrieve it’s native value.
Instance Method Summary collapse
-
#initialize(message = "#{Spotify::API.error_message(self)} (#{to_i})") ⇒ APIError
constructor
A new instance of APIError.
-
#to_i ⇒ Integer
Error code.
Constructor Details
Class Attribute Details
.to_i ⇒ Integer (readonly)
Returns error code.
38 39 40 |
# File 'lib/spotify/error.rb', line 38 def to_i @to_i end |
Class Method Details
.from_native(error, context) ⇒ Error?
Returns an error if applicable.
18 19 20 21 22 23 |
# File 'lib/spotify/error.rb', line 18 def from_native(error, context) error_class = @@code_to_class.fetch(error) do raise ArgumentError, "unknown error code: #{error}" end error_class.new if error_class end |
.to_native(error, context) ⇒ Symbol
From an error, retrieve it’s native value.
29 30 31 32 33 34 35 |
# File 'lib/spotify/error.rb', line 29 def to_native(error, context) if error error.to_i else 0 end end |
Instance Method Details
#to_i ⇒ Integer
Returns error code.
54 55 56 |
# File 'lib/spotify/error.rb', line 54 def to_i self.class.to_i end |