lib/httpx/resolver/system.rb in httpx-0.3.0 vs lib/httpx/resolver/system.rb in httpx-0.3.1

- old
+ new

@@ -5,10 +5,15 @@ module HTTPX class Resolver::System include Resolver::ResolverMixin + RESOLV_ERRORS = [Resolv::ResolvError, + Resolv::DNS::Requester::RequestError, + Resolv::DNS::EncodeError, + Resolv::DNS::DecodeError].freeze + def initialize(_, options) @options = Options.new(options) roptions = @options.resolver_options @state = :idle @resolver = Resolv::DNS.new(roptions.nil? ? nil : roptions) @@ -24,10 +29,13 @@ end def <<(channel) hostname = channel.uri.host addresses = ip_resolve(hostname) || system_resolve(hostname) || @resolver.getaddresses(hostname) - addresses.empty? ? emit_resolve_error(channel, hostname) : emit_addresses(channel, addresses) + return emit_resolve_error(channel, hostname) if addresses.empty? + emit_addresses(channel, addresses) + rescue Errno::EHOSTUNREACH, *RESOLV_ERRORS => e + emit_resolve_error(channel, hostname, e) end def uncache(*); end end end