mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-19 13:01:22 +00:00
protocols/gossipsub: Implement std::error::Error for error types (#2254)
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
This commit is contained in:
@ -14,6 +14,9 @@
|
||||
- Allow `message_id_fn`s to accept closures that capture variables.
|
||||
[PR 2103](https://github.com/libp2p/rust-libp2p/pull/2103)
|
||||
|
||||
- Implement std::error::Error for error types.
|
||||
[PR 2254](https://github.com/libp2p/rust-libp2p/pull/2254)
|
||||
|
||||
# 0.32.0 [2021-07-12]
|
||||
|
||||
- Update dependencies.
|
||||
|
@ -40,6 +40,22 @@ pub enum PublishError {
|
||||
TransformFailed(std::io::Error),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for PublishError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for PublishError {
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
match self {
|
||||
Self::SigningError(err) => Some(err),
|
||||
Self::TransformFailed(err) => Some(err),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Error associated with subscribing to a topic.
|
||||
#[derive(Debug)]
|
||||
pub enum SubscriptionError {
|
||||
@ -49,6 +65,21 @@ pub enum SubscriptionError {
|
||||
NotAllowed,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for SubscriptionError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for SubscriptionError {
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
match self {
|
||||
Self::PublishError(err) => Some(err),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SigningError> for PublishError {
|
||||
fn from(error: SigningError) -> Self {
|
||||
PublishError::SigningError(error)
|
||||
@ -95,6 +126,14 @@ pub enum ValidationError {
|
||||
TransformFailed,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for ValidationError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for ValidationError {}
|
||||
|
||||
impl From<std::io::Error> for GossipsubHandlerError {
|
||||
fn from(error: std::io::Error) -> GossipsubHandlerError {
|
||||
GossipsubHandlerError::Io(error)
|
||||
|
Reference in New Issue
Block a user