hopr_transport/
errors.rs

1use thiserror::Error;
2
3pub use hopr_transport_network::errors::NetworkingError;
4pub use hopr_transport_protocol::errors::ProtocolError;
5
6/// Errors produced by the crate.
7#[derive(Error, Debug)]
8pub enum HoprTransportError {
9    #[error("API error: {0}")]
10    Api(String),
11
12    #[error("General error: {0}")]
13    General(#[from] hopr_primitive_types::errors::GeneralError),
14
15    #[error("Db error: {0}")]
16    Db(#[from] hopr_db_sql::api::errors::DbError),
17
18    // TODO(20250114): Unify all Databse API functionality in the db_api crate and remove this error.
19    #[error("Db error: {0}")]
20    Database(#[from] hopr_db_sql::errors::DbSqlError),
21
22    #[error("Path error: {0}")]
23    Path(#[from] hopr_path::errors::PathError),
24
25    #[error("Protocol error: {0}")]
26    Protocol(#[from] hopr_transport_protocol::errors::ProtocolError),
27
28    #[error("Transport session error: {0}")]
29    Session(#[from] hopr_transport_session::errors::TransportSessionError),
30
31    #[error("Packet error: {0}")]
32    Packet(#[from] hopr_crypto_packet::errors::PacketError),
33
34    #[error("Type error: {0}")]
35    Types(#[from] hopr_internal_types::errors::CoreTypesError),
36
37    #[error("Network monitoring error: {0}")]
38    NetworkError(#[from] hopr_transport_network::errors::NetworkingError),
39}
40
41/// Result produced by the crate, uses the [HoprTransportError] as the error type.
42pub type Result<T> = core::result::Result<T, HoprTransportError>;