Class: Strava::Errors::RatelimitError

Inherits:
Faraday::ClientError
  • Object
show all
Defined in:
lib/strava/errors/ratelimit_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_response, error_message = nil) ⇒ RatelimitError

Returns a new instance of RatelimitError.



8
9
10
11
12
13
14
15
16
17
# File 'lib/strava/errors/ratelimit_error.rb', line 8

def initialize(http_response, error_message = nil)
  @response = http_response.response
  @ratelimit = Strava::Api::Ratelimit.new(@response)
  @error_message = error_message || message
  super({
    status: http_response.status,
    headers: http_response.response_headers,
    body: http_response.body
  })
end

Instance Attribute Details

#error_messageObject (readonly)

Returns the value of attribute error_message.



6
7
8
# File 'lib/strava/errors/ratelimit_error.rb', line 6

def error_message
  @error_message
end

#http_responseObject (readonly)

Returns the value of attribute http_response.



6
7
8
# File 'lib/strava/errors/ratelimit_error.rb', line 6

def http_response
  @http_response
end

#ratelimitObject (readonly)

Returns the value of attribute ratelimit.



6
7
8
# File 'lib/strava/errors/ratelimit_error.rb', line 6

def ratelimit
  @ratelimit
end

Instance Method Details

#errorsObject



27
28
29
# File 'lib/strava/errors/ratelimit_error.rb', line 27

def errors
  response[:body]['errors']
end

#headersObject



23
24
25
# File 'lib/strava/errors/ratelimit_error.rb', line 23

def headers
  response[:headers]
end

#messageObject



19
20
21
# File 'lib/strava/errors/ratelimit_error.rb', line 19

def message
  response[:body]['message'] || super
end