-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throw DNSError in getaddrinfo (hide UVError) #15879
Conversation
ae3d1f8
to
d2d4b4f
Compare
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, UV_EAI_FAIL, UV_EAI_NODATA] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, an assert is not appropriate here. If the code is not in this list, rethrow it so the user can see what the code actually was.
@vtjnash any interest in merging this? |
yes, just waiting to see Tony's comment addressed (remove the assert and rethrow the UVError if it wasn't one of the expected ones) |
@@ -553,7 +563,7 @@ function uv_getaddrinfocb(req::Ptr{Void}, status::Cint, addrinfo::Ptr{Void}) | |||
cb = unsafe_pointer_to_objref(data)::Function | |||
pop!(callback_dict,cb) # using pop forces an error if cb not in callback_dict | |||
if status != 0 || addrinfo == C_NULL | |||
cb(UVError("getaddrinfo callback",status)) | |||
cb(UVError("uv_getaddrinfodb received an unexpected status code", status)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uv_getaddrinfocb
@vtjnash OK, done. |
eventloop(), host, C_NULL, cb, uv_jl_getaddrinfocb::Ptr{Void}) | ||
if status == UV_EINVAL | ||
throw(ArgumentError("Invalid uv_getaddrinfo() agument")) | ||
elseif status in [UV_ENOMEM, UV_ENOBUFS] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ENOBUFS isn't really an OutOfMemoryError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is in this case.
f9fb0b9
to
b75a720
Compare
@@ -171,6 +171,7 @@ export | |||
TypeError, | |||
AssertionError, | |||
UnicodeError, | |||
DNSError, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it's going to be exported, it needs docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. I've un-exported for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's thrown, then it should be exported, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't export UVError - we could export DNSError if it's documented and we think packages might want to throw it though
Throw UVError when an unexpected code is received.
6864480
to
c3a3340
Compare
squashed |
@vtjnash bump |
See #14972 and #7841 and #6825 (comment)