Sha256: 8b58a24d9440cb8ee0682cf18e8b616de0065129593481a9940014b0c2abbf6b

Contents?: true

Size: 783 Bytes

Versions: 2

Compression:

Stored size: 783 Bytes

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

  ConnectTimeoutError = Class.new(TimeoutError)

  ResolveError = Class.new(Error)

  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

2 entries across 2 versions & 1 rubygems

Version Path
httpx-0.3.1 lib/httpx/errors.rb
httpx-0.3.0 lib/httpx/errors.rb