Sha256: 3c4944e5a1baeef6654b32e602514216bb72c7bf7b106b730d99f642d20f9358

Contents?: true

Size: 1.05 KB

Versions: 16

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module HTTPX
  Error = Class.new(StandardError)

  UnsupportedSchemeError = Class.new(Error)

  TimeoutError = Class.new(Error) do
    attr_reader :timeout

    def initialize(timeout, message)
      @timeout = timeout
      super(message)
    end

    def to_connection_error
      ex = ConnectTimeoutError.new(@timeout, message)
      ex.set_backtrace(backtrace)
      ex
    end
  end

  TotalTimeoutError = Class.new(TimeoutError)

  ConnectTimeoutError = Class.new(TimeoutError)

  ResolveError = Class.new(Error)

  NativeResolveError = Class.new(ResolveError) do
    attr_reader :connection, :host
    def initialize(connection, host, message = "Can't resolve #{host}")
      @connection = connection
      @host = host
      super(message)
    end
  end

  HTTPError = Class.new(Error) do
    attr_reader :response

    def initialize(response)
      @response = response
      super("HTTP Error: #{@response.status}")
    end

    def status
      @response.status
    end
  end

  MisdirectedRequestError = Class.new(HTTPError)
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
httpx-0.9.0 lib/httpx/errors.rb
httpx-0.8.2 lib/httpx/errors.rb
httpx-0.8.1 lib/httpx/errors.rb
httpx-0.8.0 lib/httpx/errors.rb
httpx-0.7.0 lib/httpx/errors.rb
httpx-0.6.7 lib/httpx/errors.rb
httpx-0.6.6 lib/httpx/errors.rb
httpx-0.6.5 lib/httpx/errors.rb
httpx-0.6.4 lib/httpx/errors.rb
httpx-0.6.3 lib/httpx/errors.rb
httpx-0.6.2 lib/httpx/errors.rb
httpx-0.6.1 lib/httpx/errors.rb
httpx-0.6.0 lib/httpx/errors.rb
httpx-0.5.1 lib/httpx/errors.rb
httpx-0.5.0 lib/httpx/errors.rb
httpx-0.4.1 lib/httpx/errors.rb