Sha256: 23d3f11fc215b2e4f00b4b39b623383e42af025189700d07a308aed09f4b146c

Contents?: true

Size: 754 Bytes

Versions: 3

Compression:

Stored size: 754 Bytes

Contents

# frozen_string_literal: true

module Strava
  module Errors
    class RatelimitError < ::Faraday::ClientError
      attr_reader :http_response, :ratelimit, :error_message

      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

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

      def headers
        response[:headers]
      end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
strava-ruby-client-2.2.0 lib/strava/errors/ratelimit_error.rb
strava-ruby-client-2.1.0 lib/strava/errors/ratelimit_error.rb
strava-ruby-client-2.0.0 lib/strava/errors/ratelimit_error.rb