hopr_transport_protocol/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
use hopr_internal_types::errors::CoreTypesError;
use hopr_primitive_types::errors::GeneralError;
use thiserror::Error;

/// Errors generated by the crate.
#[derive(Error, Debug)]
pub enum ProtocolError {
    #[error("tx queue is full, retry later")]
    Retry,

    #[error("payment channel is closed")]
    ChannelClosed,

    #[error("payment channel was not found")]
    ChannelNotFound,

    #[error("timeout on protocol operation")]
    Timeout,

    #[error("invalidate acknowledgement signature")]
    InvalidSignature,

    #[error("underlying transport error while sending packet: {0}")]
    TransportError(String),

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

    #[error("Failed to notify an external process: {0}")]
    Notification(String),

    #[error("Ticket aggregation error: {0}")]
    ProtocolTicketAggregation(String),

    #[error("General error {0}")]
    GeneralError(#[from] GeneralError),

    #[error("Core error {0}")]
    CoreError(#[from] CoreTypesError),

    #[error("Failed on a logical error: {0}")]
    Logic(String),
}

/// Result used by the crate, based on the [ProtocolError] error type.
pub type Result<T> = core::result::Result<T, ProtocolError>;