class Echonest::Error

Constants

ERRORS

Attributes

error_code[R]
response[R]

Public Class Methods

new(error_code, response = nil) click to toggle source
# File lib/echonest-ruby-api/error.rb, line 16
def initialize(error_code, response = nil)
  @error_code = error_code
  @response = response
end

Public Instance Methods

description() click to toggle source
# File lib/echonest-ruby-api/error.rb, line 21
def description
  ERRORS[@error_code.to_s]
end
details() click to toggle source
# File lib/echonest-ruby-api/error.rb, line 25
def details
  if error_code == 3
    # Returns a hash similar to {"remaining"=>0, "limit"=>20, "used"=>29}.
    Hash[response.headers.select{|k,v| k =~ /x-ratelimit/}.
      map{ |k,v| [k.sub('x-ratelimit-', ''), v.first.to_i] }]
  end
end