Sha256: 71f55df6aeb5c5640346c9b6bf4b15630578d32788f1529eae9eda5ddaf20a34
Contents?: true
Size: 849 Bytes
Versions: 1
Compression:
Stored size: 849 Bytes
Contents
# frozen_string_literal: true module Strava module Web class RaiseResponseError < ::Faraday::Middleware CLIENT_ERROR_STATUSES = (400...600) 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
strava-ruby-client-2.2.0 | lib/strava/web/raise_response_error.rb |