Sha256: 0fc5ac7497f5ada77ea7bec812f553e3630790b090b74a2d311719e5907542b7

Contents?: true

Size: 769 Bytes

Versions: 7

Compression:

Stored size: 769 Bytes

Contents

module Faraday
  class Response::RaiseError < Response::Middleware
    ClientErrorStatuses = 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.new(
                %{407 "Proxy Authentication Required "},
                response_values(env))
      when ClientErrorStatuses
        raise Faraday::ClientError, response_values(env)
      when nil
        raise Faraday::NilStatusError, response_values(env)
      end
    end

    def response_values(env)
      {:status => env.status, :headers => env.response_headers, :body => env.body}
    end
  end
end

Version data entries

7 entries across 6 versions & 2 rubygems

Version Path
faraday-0.17.6 lib/faraday/response/raise_error.rb
faraday-0.17.5 lib/faraday/response/raise_error.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/faraday-0.17.4/lib/faraday/response/raise_error.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/faraday-0.17.3/lib/faraday/response/raise_error.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/faraday-0.17.3/lib/faraday/response/raise_error.rb
faraday-0.17.4 lib/faraday/response/raise_error.rb
faraday-0.17.3 lib/faraday/response/raise_error.rb