hopr_transport_protocol/
errors.rs

1use hopr_internal_types::errors::CoreTypesError;
2use hopr_primitive_types::errors::GeneralError;
3use thiserror::Error;
4
5/// Errors generated by the crate.
6#[derive(Error, Debug)]
7pub enum ProtocolError {
8    #[error("tx queue is full, retry later")]
9    Retry,
10
11    #[error("payment channel is closed")]
12    ChannelClosed,
13
14    #[error("payment channel was not found")]
15    ChannelNotFound,
16
17    #[error("timeout on protocol operation")]
18    Timeout,
19
20    #[error("no surb found for the given pseudonym")]
21    NoSurb,
22
23    #[error("invalidate acknowledgement signature")]
24    InvalidSignature,
25
26    #[error("underlying transport error while sending packet: {0}")]
27    TransportError(String),
28
29    #[error("db error {0}")]
30    DatabaseError(#[from] hopr_db_api::errors::DbError),
31
32    #[error("Failed to notify an external process: {0}")]
33    Notification(String),
34
35    #[error("Ticket aggregation error: {0}")]
36    ProtocolTicketAggregation(String),
37
38    #[error("General error {0}")]
39    GeneralError(#[from] GeneralError),
40
41    #[error("Core error {0}")]
42    CoreError(#[from] CoreTypesError),
43
44    #[error("Failed on a logical error: {0}")]
45    Logic(String),
46}
47
48/// Result used by the crate, based on the [ProtocolError] error type.
49pub type Result<T> = core::result::Result<T, ProtocolError>;