Skip to content
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

Make accept() throw more useful errors #7822

Merged
merged 1 commit into from
Aug 4, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions base/stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ end

function accept(server::UVServer, client::AsyncStream)
if server.status != StatusActive
error("server not connected; make sure \"listen\" has been called")
throw(ArgumentError("server not connected; make sure \"listen\" has been called"))
end
while isopen(server)
err = accept_nonblock(server,client)
Expand All @@ -862,7 +862,7 @@ function accept(server::UVServer, client::AsyncStream)
end
stream_wait(server,server.connectnotify)
end
error("server was closed while attempting to accept a client")
uv_error("accept", UV_ECONNABORTED)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This calls into question what uv_error really means. After all, this error is not returned by libuv. I also generally dislike classifying errors according to which library threw them, but that's not specific to this PR of course.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason libuv isn't returning this error is because we explicitly check on the julia side for the condition that would cause libuv to return this error. If we didn't have that isopen(server) check, this is the error that would be raised by libuv.

I guess we could just map this to a SystemError instead, which I would have done, except that I wanted to be consistent with the rest of our socket/IO code. I guess we could just create an IOError type that holds the UV_* codes instead (which are really just errno codes anyway).

end

const BACKLOG_DEFAULT = 511
Expand Down