lib/httpx/resolver/resolver_mixin.rb in httpx-0.6.4 vs lib/httpx/resolver/resolver_mixin.rb in httpx-0.6.5

- old
+ new

@@ -36,11 +36,11 @@ end def early_resolve(connection, hostname: connection.origin.host) addresses = connection.addresses || ip_resolve(hostname) || - Resolver.cached_lookup(hostname) || + (@resolver_options.cache && Resolver.cached_lookup(hostname)) || system_resolve(hostname) return unless addresses emit_addresses(connection, addresses) end @@ -56,13 +56,17 @@ ips.map { |ip| IPAddr.new(ip) } end def emit_resolve_error(connection, hostname, ex = nil) + emit(:error, connection, resolve_error(hostname, ex)) + end + + def resolve_error(hostname, ex = nil) message = ex ? ex.message : "Can't resolve #{hostname}" error = ResolveError.new(message) error.set_backtrace(ex ? ex.backtrace : caller) - emit(:error, connection, error) + error end end end end