hopr_internal_types/
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
use hopr_crypto_types::errors::CryptoError;
use multiaddr::Error as MultiaddrError;
use thiserror::Error;

/// Enumeration of all core type related errors.
#[derive(Error, Debug)]
pub enum CoreTypesError {
    #[error("{0}")]
    InvalidInputData(String),

    #[error("failed to parse/deserialize the data of {0}")]
    ParseError(String),

    #[error("Arithmetic error: {0}")]
    ArithmeticError(String),

    #[error("Invalid ticket signature or wrong ticket recipient")]
    InvalidTicketRecipient,

    #[error("Cannot acknowledge self-signed tickets. Ticket sender and recipient must be different")]
    LoopbackTicket,

    #[error("size of the packet payload has been exceeded")]
    PayloadSizeExceeded,

    #[error(transparent)]
    InvalidMultiaddr(#[from] MultiaddrError),

    #[error(transparent)]
    CryptoError(#[from] CryptoError),

    #[error(transparent)]
    GeneralError(#[from] hopr_primitive_types::errors::GeneralError),
}

pub type Result<T> = core::result::Result<T, CoreTypesError>;