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
|
@ -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…
Add table
Add a link
Reference in a new issue