Sha256: 60a8c6b7ee1ccf6911ae714cf38a5712823b10e6ad3fd4ce569a7c9063ea87bf

Contents?: true

Size: 1.16 KB

Versions: 26

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

module HTTPX
  class Error < StandardError; end

  class UnsupportedSchemeError < Error; end

  class TimeoutError < Error
    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

  class TotalTimeoutError < TimeoutError; end

  class ConnectTimeoutError < TimeoutError; end

  class SettingsTimeoutError < TimeoutError; end

  class ResolveTimeoutError < TimeoutError; end

  class ResolveError < Error; end

  class NativeResolveError < ResolveError
    attr_reader :connection, :host

    def initialize(connection, host, message = "Can't resolve #{host}")
      @connection = connection
      @host = host
      super(message)
    end
  end

  class HTTPError < Error
    attr_reader :response

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

    def status
      @response.status
    end
  end

  class MisdirectedRequestError < HTTPError; end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
httpx-0.18.2 lib/httpx/errors.rb
httpx-0.18.1 lib/httpx/errors.rb
httpx-0.18.0 lib/httpx/errors.rb
httpx-0.17.0 lib/httpx/errors.rb
httpx-0.16.1 lib/httpx/errors.rb
httpx-0.16.0 lib/httpx/errors.rb