diff --git a/base/socket.jl b/base/socket.jl index 367a5e149c321..84e61a98d38c4 100644 --- a/base/socket.jl +++ b/base/socket.jl @@ -582,13 +582,27 @@ function getaddrinfo(cb::Function, host::ASCIIString) end getaddrinfo(cb::Function, host::AbstractString) = getaddrinfo(cb,ascii(host)) + +type DNSError <: Exception + uverror::UVError + host::AbstractString +end + +function show(io::IO, e::DNSError) + print(io, "DNSError: ", e.host, ", ") + show(io, e.uverror) +end + function getaddrinfo(host::ASCIIString) c = Condition() getaddrinfo(host) do IP notify(c,IP) end ip = wait(c) - isa(ip,UVError) && throw(ip) + if isa(ip,UVError) + @assert ip.code in [UV_EAI_NONAME, UV_EAI_AGAIN] + throw(DNSError(ip, host)) + end return ip::IPAddr end getaddrinfo(host::AbstractString) = getaddrinfo(ascii(host))