Improved error-handling in config (fixes #98)
This commit is contained in:
parent
e3c93e72f2
commit
9ec7356d10
2 changed files with 6 additions and 8 deletions
|
@ -119,7 +119,7 @@ impl Connection {
|
|||
println!("Added {} to trusted certificates.", cert_path);
|
||||
}
|
||||
let connector = builder.build()?;
|
||||
let stream = Box::new(TcpStream::connect(&config.socket_addr(), handle)
|
||||
let stream = Box::new(TcpStream::connect(&config.socket_addr()?, handle)
|
||||
.map_err(|e| {
|
||||
let res: error::Error = e.into();
|
||||
res
|
||||
|
@ -134,7 +134,7 @@ impl Connection {
|
|||
} else {
|
||||
Ok(ConnectionFuture::Unsecured(
|
||||
config,
|
||||
TcpStream::connect(&config.socket_addr(), handle),
|
||||
TcpStream::connect(&config.socket_addr()?, handle),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -305,12 +305,10 @@ impl Config {
|
|||
|
||||
/// Gets the server and port as a `SocketAddr`.
|
||||
/// This panics when server is not specified or the address is malformed.
|
||||
pub fn socket_addr(&self) -> SocketAddr {
|
||||
format!("{}:{}", self.server(), self.port())
|
||||
.to_socket_addrs()
|
||||
.unwrap()
|
||||
.next()
|
||||
.unwrap()
|
||||
pub fn socket_addr(&self) -> Result<SocketAddr> {
|
||||
format!("{}:{}", self.server(), self.port()).to_socket_addrs()
|
||||
.map(|mut i| i.next().unwrap())
|
||||
.map_err(|e| e.into())
|
||||
}
|
||||
|
||||
/// Gets the server password specified in the configuration.
|
||||
|
|
Loading…
Reference in a new issue