Sha256: 6f1450e41c92d36f44fa954c147692592d557b1effbab2db4dc20c42eecb1c4b

Contents?: true

Size: 1.58 KB

Versions: 18

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

module HTTPX
  class Error < StandardError; end

  class UnsupportedSchemeError < Error; end

  class ConnectionError < 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 RequestTimeoutError < TimeoutError
    attr_reader :request

    def initialize(request, response, timeout)
      @request = request
      @response = response
      super(timeout, "Timed out after #{timeout} seconds")
    end

    def marshal_dump
      [message]
    end
  end

  class ReadTimeoutError < RequestTimeoutError; end

  class WriteTimeoutError < RequestTimeoutError; 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

18 entries across 18 versions & 1 rubygems

Version Path
httpx-0.24.7 lib/httpx/errors.rb
httpx-0.24.6 lib/httpx/errors.rb
httpx-0.24.5 lib/httpx/errors.rb
httpx-0.24.4 lib/httpx/errors.rb
httpx-0.24.3 lib/httpx/errors.rb
httpx-0.24.2 lib/httpx/errors.rb
httpx-0.24.1 lib/httpx/errors.rb
httpx-0.24.0 lib/httpx/errors.rb
httpx-0.23.4 lib/httpx/errors.rb
httpx-0.23.3 lib/httpx/errors.rb
httpx-0.23.2 lib/httpx/errors.rb
httpx-0.23.1 lib/httpx/errors.rb
httpx-0.23.0 lib/httpx/errors.rb
httpx-0.22.5 lib/httpx/errors.rb
httpx-0.22.4 lib/httpx/errors.rb
httpx-0.22.3 lib/httpx/errors.rb
httpx-0.22.2 lib/httpx/errors.rb
httpx-0.22.1 lib/httpx/errors.rb