Sha256: 26a6b6b2123c3c29837117d9daa7552bb46a8c7d7ed37e45e266f94104183762

Contents?: true

Size: 1.14 KB

Versions: 14

Compression:

Stored size: 1.14 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)

  ResolveTimeoutError = 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} #{@response.headers}\n#{@response.body}")
    end

    def status
      @response.status
    end
  end

  MisdirectedRequestError = Class.new(HTTPError)
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
httpx-0.14.5 lib/httpx/errors.rb
httpx-0.14.4 lib/httpx/errors.rb
httpx-0.14.3 lib/httpx/errors.rb
httpx-0.14.2 lib/httpx/errors.rb
httpx-0.14.1 lib/httpx/errors.rb
httpx-0.14.0 lib/httpx/errors.rb
httpx-0.13.2 lib/httpx/errors.rb
httpx-0.13.1 lib/httpx/errors.rb
httpx-0.13.0 lib/httpx/errors.rb
httpx-0.12.0 lib/httpx/errors.rb
httpx-0.11.3 lib/httpx/errors.rb
httpx-0.11.2 lib/httpx/errors.rb
httpx-0.11.1 lib/httpx/errors.rb
httpx-0.11.0 lib/httpx/errors.rb