fix(swarm): better error message for failed DialPeerConditions

Closes #4407.

Pull-Request: #4409.
This commit is contained in:
chirag-bgh
2023-09-06 17:25:23 +05:30
committed by GitHub
parent 6f0895fee1
commit 94a136c722
5 changed files with 13 additions and 6 deletions

View File

@@ -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."