From da743ec4868d128313ea026a776d40086f7941e7 Mon Sep 17 00:00:00 2001 From: Divma <26765164+divagant-martian@users.noreply.github.com> Date: Mon, 24 Jul 2023 14:52:51 -0500 Subject: [PATCH] fix(swarm): display cause of denied listen error The display of `ListenError` could be more helpful. The inner `cause` already implements `Error` which in turn requires `Display`. This is then just a matter of using said impl requirement to get an useful display Pull-Request: #4232. --- Cargo.lock | 2 +- Cargo.toml | 2 +- swarm/CHANGELOG.md | 6 ++++++ swarm/Cargo.toml | 2 +- swarm/src/lib.rs | 4 ++-- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6c215e16c84..e89447b4edb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3150,7 +3150,7 @@ dependencies = [ [[package]] name = "libp2p-swarm" -version = "0.43.1" +version = "0.43.2" dependencies = [ "async-std", "either", diff --git a/Cargo.toml b/Cargo.toml index 5a3885ed161..07ac8ab9e85 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,7 +87,7 @@ libp2p-quic = { version = "0.8.0-alpha", path = "transports/quic" } libp2p-relay = { version = "0.16.1", path = "protocols/relay" } libp2p-rendezvous = { version = "0.13.0", path = "protocols/rendezvous" } libp2p-request-response = { version = "0.25.1", path = "protocols/request-response" } -libp2p-swarm = { version = "0.43.1", path = "swarm" } +libp2p-swarm = { version = "0.43.2", path = "swarm" } libp2p-swarm-derive = { version = "0.33.0", path = "swarm-derive" } libp2p-swarm-test = { version = "0.2.0", path = "swarm-test" } libp2p-tcp = { version = "0.40.0", path = "transports/tcp" } diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index ecf49a38236..b5c33d90eb4 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.43.2 - unreleased +- Display the cause of a `ListenError::Denied`. + See [PR 4232] + +[PR 4232]: https://github.com/libp2p/rust-libp2p/pull/4158 + ## 0.43.1 - Do not announce external address candidate before address translation, unless translation does not apply. diff --git a/swarm/Cargo.toml b/swarm/Cargo.toml index 10bd747e4c8..752491cda7e 100644 --- a/swarm/Cargo.toml +++ b/swarm/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-swarm" edition = "2021" rust-version = { workspace = true } description = "The libp2p swarm" -version = "0.43.1" +version = "0.43.2" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index f8c8e855bd5..867e49410c5 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -1684,8 +1684,8 @@ impl fmt::Display for ListenError { ListenError::Transport(_) => { write!(f, "Listen error: Failed to negotiate transport protocol(s)") } - ListenError::Denied { .. } => { - write!(f, "Listen error") + ListenError::Denied { cause } => { + write!(f, "Listen error: Denied: {cause}") } ListenError::LocalPeerId { endpoint } => { write!(f, "Listen error: Local peer ID at {endpoint:?}.")