You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an application in which I want to try to set up a server on a specific port, but if that port is taken (i.e., an AddrInUse error is raised), it should fall back to any port (i.e., port 0). Unfortunately, since hyper's error type is now opaque (as of 5d3c472), I can no longer easily see if that was the cause of an error raised by Server::try_bind.
While I could construct a TcpListener myself and then pass that listener's Incoming to Server::builder, that's an unfortunate amount of extra boilerplate. Perhaps it would make sense to expose an as_io_error(&self) -> Option<&io::Error> on hyper::Error?
The text was updated successfully, but these errors were encountered:
That'd be nice, but is there a particular reason you don't want to expose the io::Error through an explicit as_io_error method? As someone pointed out on IRC when I asked about it, cause() isn't really intended to be used as a way to figure out if a particular error occurred. Part of this is because causes form a chain, and you don't technically know how deep you have to go. And more importantly, the error nesting could change between versions.
I'm not especially against some form of as_io_error, I was just thinking that people may wish to access the errors they created themselves, like from a Payload or Service, and suggested something that might solve all cases.
Oh, yeah, I think having both is probably a good idea! I think my concern about cause nesting would make it pretty difficult to extract user errors from behind a hyper::Error nonetheless, but at least it would be possible!
I have an application in which I want to try to set up a server on a specific port, but if that port is taken (i.e., an
AddrInUse
error is raised), it should fall back to any port (i.e., port 0). Unfortunately, since hyper's error type is now opaque (as of 5d3c472), I can no longer easily see if that was the cause of an error raised byServer::try_bind
.While I could construct a
TcpListener
myself and then pass that listener'sIncoming
toServer::builder
, that's an unfortunate amount of extra boilerplate. Perhaps it would make sense to expose anas_io_error(&self) -> Option<&io::Error>
onhyper::Error
?The text was updated successfully, but these errors were encountered: