Exception: Flattr::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/flattr/error.rb

Overview

Custom error class for rescuing from all Flattr errors

Direct Known Subclasses

ClientError, ServerError

Defined Under Namespace

Classes: BadGateway, BadRequest, ClientError, Forbidden, InternalServerError, NotAcceptable, NotFound, ServerError, Unauthorized

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, http_headers) ⇒ Error

Private: Initializes a new Error object

message - Error message http_headers - Hash with http_headers

Returns a Flattr::Error



12
13
14
15
# File 'lib/flattr/error.rb', line 12

def initialize(message, http_headers)
  @http_headers = Hash[http_headers]
  super(message)
end

Instance Attribute Details

#http_headersObject (readonly)

Returns the value of attribute http_headers.



4
5
6
# File 'lib/flattr/error.rb', line 4

def http_headers
  @http_headers
end

Instance Method Details

#ratelimit_limitInteger

Returns:

  • (Integer)


18
19
20
# File 'lib/flattr/error.rb', line 18

def ratelimit_limit
  @http_headers.values_at('x-ratelimit-limit', 'X-RateLimit-Limit').detect{|value| value}.to_i
end

#ratelimit_remainingInteger

Returns:

  • (Integer)


23
24
25
# File 'lib/flattr/error.rb', line 23

def ratelimit_remaining
  @http_headers.values_at('x-ratelimit-remaining', 'X-RateLimit-Remaining').detect{|value| value}.to_i
end