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("invalidate acknowledgement signature")]
21    InvalidSignature,
22
23    #[error("underlying transport error while sending packet: {0}")]
24    TransportError(String),
25
26    #[error("db error {0}")]
27    DatabaseError(#[from] hopr_db_api::errors::DbError),
28
29    #[error("Failed to notify an external process: {0}")]
30    Notification(String),
31
32    #[error("Ticket aggregation error: {0}")]
33    ProtocolTicketAggregation(String),
34
35    #[error("General error {0}")]
36    GeneralError(#[from] GeneralError),
37
38    #[error("Core error {0}")]
39    CoreError(#[from] CoreTypesError),
40
41    #[error("Failed on a logical error: {0}")]
42    Logic(String),
43}
44
45/// Result used by the crate, based on the [ProtocolError] error type.
46pub type Result<T> = core::result::Result<T, ProtocolError>;