Skip to content

Commit

Permalink
fix(swarm): display cause of denied listen error
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
divagant-martian authored Jul 24, 2023
1 parent 7f2ef01 commit da743ec
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
6 changes: 6 additions & 0 deletions swarm/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion swarm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
4 changes: 2 additions & 2 deletions swarm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}.")
Expand Down

0 comments on commit da743ec

Please sign in to comment.