Sha256: e4184682e01992ed2b7d3a51014ead8f9fb8e1132d3763b9307dac243404acf6
Contents?: true
Size: 856 Bytes
Versions: 2
Compression:
Stored size: 856 Bytes
Contents
# frozen_string_literal: true module Strava module Web class RaiseResponseError < ::Faraday::Middleware CLIENT_ERROR_STATUSES = (400...600).freeze def on_complete(env) case env[:status] when 404 raise Faraday::ResourceNotFound, response_values(env) when 407 # mimic the behavior that we get with proxy requests with HTTPS raise Faraday::ConnectionFailed, %(407 "Proxy Authentication Required ") when 429 raise Strava::Errors::RatelimitError.new(env, 'Too Many Requests') when CLIENT_ERROR_STATUSES raise Strava::Errors::Fault, response_values(env) end end def response_values(env) { status: env.status, headers: env.response_headers, body: env.body } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
strava-ruby-client-2.1.0 | lib/strava/web/raise_response_error.rb |
strava-ruby-client-2.0.0 | lib/strava/web/raise_response_error.rb |