Skip to content

Commit

Permalink
P2P replace DNS panic with map_err (#3383)
Browse files Browse the repository at this point in the history
Replace panic on DNS resolution error with map_err to bubble
up error to the caller

Co-authored-by: Nym Seddon <[email protected]>
  • Loading branch information
unseddd and Nym Seddon authored Jul 17, 2020
1 parent 824c51a commit d78980c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions p2p/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ impl<'de> Visitor<'de> for PeerAddrs {
Ok(ip) => peers.push(PeerAddr(ip)),
// If that fails it's probably a DNS record
Err(_) => {
let socket_addrs = entry
.to_socket_addrs()
.unwrap_or_else(|_| panic!("Unable to resolve DNS: {}", entry));
let socket_addrs = entry.to_socket_addrs().map_err(|_| {
serde::de::Error::custom(format!("Unable to resolve DNS: {}", entry))
})?;
peers.append(&mut socket_addrs.map(PeerAddr).collect());
}
}
Expand Down

0 comments on commit d78980c

Please sign in to comment.