mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-05-03 14:42:16 +00:00
Implement std::error::Error for InboundFailure and OutboundFailure (#2033)
Co-authored-by: Max Inden <mail@max-inden.de>
This commit is contained in:
parent
7386fd7fd8
commit
385af35047
@ -1,6 +1,8 @@
|
|||||||
# 0.11.0 [unreleased]
|
# 0.11.0 [unreleased]
|
||||||
|
|
||||||
- Update `libp2p-swarm`.
|
- Update `libp2p-swarm`.
|
||||||
|
- Implement `std::error::Error` for `InboundFailure` and `OutboundFailure` [PR
|
||||||
|
2033](https://github.com/libp2p/rust-libp2p/pull/2033).
|
||||||
|
|
||||||
# 0.10.0 [2021-03-17]
|
# 0.10.0 [2021-03-17]
|
||||||
|
|
||||||
|
@ -181,6 +181,19 @@ pub enum OutboundFailure {
|
|||||||
UnsupportedProtocols,
|
UnsupportedProtocols,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for OutboundFailure {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
match self {
|
||||||
|
OutboundFailure::DialFailure => write!(f, "Failed to dial the requested peer"),
|
||||||
|
OutboundFailure::Timeout => write!(f, "Timeout while waiting for a response"),
|
||||||
|
OutboundFailure::ConnectionClosed => write!(f, "Connection was closed before a response was received"),
|
||||||
|
OutboundFailure::UnsupportedProtocols => write!(f, "The remote supports none of the requested protocols")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::error::Error for OutboundFailure {}
|
||||||
|
|
||||||
/// Possible failures occurring in the context of receiving an
|
/// Possible failures occurring in the context of receiving an
|
||||||
/// inbound request and sending a response.
|
/// inbound request and sending a response.
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
@ -201,6 +214,19 @@ pub enum InboundFailure {
|
|||||||
ResponseOmission,
|
ResponseOmission,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for InboundFailure {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
match self {
|
||||||
|
InboundFailure::Timeout => write!(f, "Timeout while receiving request or sending response"),
|
||||||
|
InboundFailure::ConnectionClosed => write!(f, "Connection was closed before a response could be sent"),
|
||||||
|
InboundFailure::UnsupportedProtocols => write!(f, "The local peer supports none of the protocols requested by the remote"),
|
||||||
|
InboundFailure::ResponseOmission => write!(f, "The response channel was dropped without sending a response to the remote")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::error::Error for InboundFailure {}
|
||||||
|
|
||||||
/// A channel for sending a response to an inbound request.
|
/// A channel for sending a response to an inbound request.
|
||||||
///
|
///
|
||||||
/// See [`RequestResponse::send_response`].
|
/// See [`RequestResponse::send_response`].
|
||||||
|
Loading…
x
Reference in New Issue
Block a user