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.
This commit is contained in:
Divma
2023-07-24 14:52:51 -05:00
committed by GitHub
parent 7f2ef013a8
commit da743ec486
5 changed files with 11 additions and 5 deletions

2
Cargo.lock generated
View File

@ -3150,7 +3150,7 @@ dependencies = [
[[package]] [[package]]
name = "libp2p-swarm" name = "libp2p-swarm"
version = "0.43.1" version = "0.43.2"
dependencies = [ dependencies = [
"async-std", "async-std",
"either", "either",

View File

@ -87,7 +87,7 @@ libp2p-quic = { version = "0.8.0-alpha", path = "transports/quic" }
libp2p-relay = { version = "0.16.1", path = "protocols/relay" } libp2p-relay = { version = "0.16.1", path = "protocols/relay" }
libp2p-rendezvous = { version = "0.13.0", path = "protocols/rendezvous" } libp2p-rendezvous = { version = "0.13.0", path = "protocols/rendezvous" }
libp2p-request-response = { version = "0.25.1", path = "protocols/request-response" } 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-derive = { version = "0.33.0", path = "swarm-derive" }
libp2p-swarm-test = { version = "0.2.0", path = "swarm-test" } libp2p-swarm-test = { version = "0.2.0", path = "swarm-test" }
libp2p-tcp = { version = "0.40.0", path = "transports/tcp" } libp2p-tcp = { version = "0.40.0", path = "transports/tcp" }

View File

@ -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 ## 0.43.1
- Do not announce external address candidate before address translation, unless translation does not apply. - Do not announce external address candidate before address translation, unless translation does not apply.

View File

@ -3,7 +3,7 @@ name = "libp2p-swarm"
edition = "2021" edition = "2021"
rust-version = { workspace = true } rust-version = { workspace = true }
description = "The libp2p swarm" description = "The libp2p swarm"
version = "0.43.1" version = "0.43.2"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT" license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p" repository = "https://github.com/libp2p/rust-libp2p"

View File

@ -1684,8 +1684,8 @@ impl fmt::Display for ListenError {
ListenError::Transport(_) => { ListenError::Transport(_) => {
write!(f, "Listen error: Failed to negotiate transport protocol(s)") write!(f, "Listen error: Failed to negotiate transport protocol(s)")
} }
ListenError::Denied { .. } => { ListenError::Denied { cause } => {
write!(f, "Listen error") write!(f, "Listen error: Denied: {cause}")
} }
ListenError::LocalPeerId { endpoint } => { ListenError::LocalPeerId { endpoint } => {
write!(f, "Listen error: Local peer ID at {endpoint:?}.") write!(f, "Listen error: Local peer ID at {endpoint:?}.")