Skip to content

Commit

Permalink
fix(swarm): better error message for failed DialPeerConditions
Browse files Browse the repository at this point in the history
Closes #4407.

Pull-Request: #4409.
  • Loading branch information
chirag-bgh authored Sep 6, 2023
1 parent 6f0895f commit 94a136c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 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 @@ -92,7 +92,7 @@ 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-server = { version = "0.12.2", path = "misc/server" }
libp2p-swarm = { version = "0.43.3", path = "swarm" }
libp2p-swarm = { version = "0.43.4", 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
7 changes: 7 additions & 0 deletions swarm/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.43.4 - unreleased

- Improve error message when `DialPeerCondition` prevents a dial.
See [PR 4409].

[PR 4409]: https://github.com/libp2p/rust-libp2p/pull/4409

## 0.43.3

- Implement `Display` for `ConnectionId`.
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.3"
version = "0.43.4"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
6 changes: 3 additions & 3 deletions swarm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1580,9 +1580,9 @@ impl fmt::Display for DialError {
f,
"Dial error: tried to dial local peer id at {endpoint:?}."
),
DialError::DialPeerConditionFalse(c) => {
write!(f, "Dial error: condition {c:?} for dialing peer was false.")
}
DialError::DialPeerConditionFalse(PeerCondition::Disconnected) => write!(f, "Dial error: dial condition was configured to only happen when disconnected (`PeerCondition::Disconnected`), but node is already connected, thus cancelling new dial."),
DialError::DialPeerConditionFalse(PeerCondition::NotDialing) => write!(f, "Dial error: dial condition was configured to only happen if there is currently no ongoing dialing attempt (`PeerCondition::NotDialing`), but a dial is in progress, thus cancelling new dial."),
DialError::DialPeerConditionFalse(PeerCondition::Always) => unreachable!("Dial peer condition is by definition true."),
DialError::Aborted => write!(
f,
"Dial error: Pending connection attempt has been aborted."
Expand Down

0 comments on commit 94a136c

Please sign in to comment.