lib/httpx/errors.rb in httpx-0.2.1 vs lib/httpx/errors.rb in httpx-0.3.0

- old
+ new

@@ -1,10 +1,27 @@ # frozen_string_literal: true module HTTPX Error = Class.new(StandardError) - TimeoutError = Class.new(Error) + 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