class Spotify::APIError
@abstract Generic error class, extended by all libspotify errors.
Attributes
to_i[R]
@return [Integer] error code
Public Class Methods
from_native(error, context)
click to toggle source
Returns an error if applicable.
@param [Integer] error @return [Error, nil] an error, unless error symbol was OK
# 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
new(message = "
click to toggle source
@param [String] message only to be supplied if overridden
Calls superclass method
# File lib/spotify/error.rb, line 49 def initialize(message = "#{Spotify::API.error_message(self)} (#{to_i})") super end
to_native(error, context)
click to toggle source
From an error, retrieve it's native value.
@param [Error] error @return [Symbol]
# File lib/spotify/error.rb, line 29 def to_native(error, context) if error error.to_i else 0 end end
Private Class Methods
error_code(number)
click to toggle source
# File lib/spotify/error.rb, line 42 def error_code(number) @to_i = number @@code_to_class[number] = self end
Public Instance Methods
to_i()
click to toggle source
@return (see .to_i)
# File lib/spotify/error.rb, line 54 def to_i self.class.to_i end