-
Notifications
You must be signed in to change notification settings - Fork 50
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
Return errors instead of panicking #130
Conversation
On a related note: |
Yes, that makes sense to me. |
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.
This looks good, but I'm still thinking ip version mismatch is a panic with the current setup.
src/top.rs
Outdated
link.enqueue_message(&self.config, rand, src, dst, message); | ||
Ok(()) | ||
} else { | ||
Err(Error::new(ErrorKind::ConnectionRefused, "host unreachable")) |
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.
nit: The error message renders like this:
Err(Os { code: 111, kind: ConnectionRefused, message: "Connection refused" })
tests/udp.rs
Outdated
let mut sim = Builder::new().ip_version(IpVersion::V6).build(); | ||
sim.client("client", async move { | ||
let _sock = bind_to_v4(0).await?; | ||
let sock = bind_to_v4(0).await; | ||
assert!(sock.is_err()); |
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.
Use unwrap_err
here as well to simplify?
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.
No, since UdpSocket
does not impl Debug
. If could however combine it with the later let else
See Issue #127.