Improved error-handling in config (fixes #98)

This commit is contained in:
Jokler 2017-10-17 00:38:59 +02:00
parent e3c93e72f2
commit 9ec7356d10
2 changed files with 6 additions and 8 deletions

View file

@ -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.