Better error message when listening on DHT

This commit is contained in:
Igor Katson 2021-09-29 19:15:04 +01:00
parent bca55891c1
commit a6a785640f
2 changed files with 8 additions and 5 deletions

View file

@ -624,10 +624,13 @@ impl Dht {
}
pub async fn with_config(config: DhtConfig) -> anyhow::Result<Self> {
let socket = match config.listen_addr {
Some(addr) => UdpSocket::bind(addr).await,
None => UdpSocket::bind("0.0.0.0:0").await,
}
.context("error binding socket")?;
Some(addr) => UdpSocket::bind(addr)
.await
.with_context(|| format!("error binding socket, address {}", addr)),
None => UdpSocket::bind("0.0.0.0:0")
.await
.context("error binding socket, address 0.0.0.0:0"),
}?;
let listen_addr = socket
.local_addr()