hopr_transport_network/
errors.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use libp2p_identity::PeerId;
use thiserror::Error;

/// Errors that can be generated by the crate.
#[derive(Error, Debug)]
pub enum NetworkingError {
    #[error("the network operation timed out after {0} seconds")]
    Timeout(u64),

    #[error("error in the messaging sub-protocol: {0}")]
    MessagingError(String),

    #[error("error while decoding message data")]
    DecodingError,

    #[error("performing an operation on own PeerId")]
    DisallowedOperationOnOwnPeerIdError,

    #[error("db error: {0}")]
    DbError(#[from] hopr_db_api::errors::DbError),

    #[error("peer does not exist")]
    NonExistingPeer,

    #[error("error while pinging peer {0}: {1}")]
    PingerError(PeerId, String),

    #[error("{0}")]
    Other(String),
}

/// Result built on top of the crate error [NetworkingError]
pub type Result<T> = core::result::Result<T, NetworkingError>;