class Spotify::Models::Error

Constants

DEFAULT

Identifies that the error is returned from some request.

ERRORS

Defines the text and status for each message known.

Attributes

message[R]
status[R]

Public Class Methods

default(args = {}) click to toggle source

Creates an error representing the site response error.

@return [Parsers::Error] a message to be shown to the user.

# File lib/spotify/models/error.rb, line 112
def self.default(args = {})
  args = Hash(args).with_indifferent_access

  self.new(:default, args)
end
max_retries() click to toggle source

Creates an error representing that the retries limit was reached.

@return [Parsers::Error] a message to be shown to the user.

# File lib/spotify/models/error.rb, line 84
def self.max_retries
  self.new(:max_retries)
end
new(type, args = {}) click to toggle source

Creates the message.

@param [Hash] type the type of the message to be shown.

@return [Parsers::Error] a message to be shown to the user.

# File lib/spotify/models/error.rb, line 47
def initialize(type, args = {})
  if type == DEFAULT
    error = {
      status:  args[:status],
      message: args[:message]
    }
  else
    error = ERRORS[type]
  end

  @status  = error[:status]
  @message = error[:message]
end
not_available() click to toggle source

Creates an error representing that the requested feature is not available yet.

@return [Parsers::Error] a message to be shown to the user.

# File lib/spotify/models/error.rb, line 94
def self.not_available
  self.new(:not_available)
end
parser_error() click to toggle source

Creates an error representing a parser error.

@return [Parsers::Error] a message to be shown to the user.

# File lib/spotify/models/error.rb, line 103
def self.parser_error
  self.new(:parser_error)
end
timeout() click to toggle source

Creates an error representing a timeout error.

@return [Parsers::Error] a message to be shown to the user.

# File lib/spotify/models/error.rb, line 66
def self.timeout
  self.new(:timeout)
end
unexpected_error() click to toggle source

Creates an error representing an unexpected error.

@return [Parsers::Error] a message to be shown to the user.

# File lib/spotify/models/error.rb, line 75
def self.unexpected_error
  self.new(:unexpected_error)
end