hopr_internal_types/
errors.rs

1use hopr_crypto_types::errors::CryptoError;
2use hopr_primitive_types::errors::GeneralError;
3use multiaddr::Error as MultiaddrError;
4use thiserror::Error;
5
6/// Enumeration of all core type related errors.
7#[derive(Error, Debug)]
8pub enum CoreTypesError {
9    #[error("{0}")]
10    InvalidInputData(String),
11
12    #[error("failed to parse/deserialize the data of {0}")]
13    ParseError(String),
14
15    #[error("arithmetic error: {0}")]
16    ArithmeticError(String),
17
18    #[error("invalid ticket signature or wrong ticket recipient")]
19    InvalidTicketRecipient,
20
21    #[error("packet acknowledgement could not be verified")]
22    InvalidAcknowledgement,
23
24    #[error("invalid winning probability value")]
25    InvalidWinningProbability,
26
27    #[error("cannot acknowledge self-signed tickets. Ticket sender and recipient must be different")]
28    LoopbackTicket,
29
30    #[error("ticket is not winning")]
31    TicketNotWinning,
32
33    #[error(transparent)]
34    InvalidMultiaddr(#[from] MultiaddrError),
35
36    #[error(transparent)]
37    CryptoError(#[from] CryptoError),
38
39    #[error(transparent)]
40    GeneralError(#[from] GeneralError),
41}
42
43/// Path selection and construction errors.
44#[derive(Error, Debug)]
45pub enum PathError {
46    #[error("path is not valid")]
47    PathNotValid,
48
49    #[error("path contains an invalid peer id: {0}")]
50    InvalidPeer(String),
51
52    #[error("path contains a unknown peer that cannot be resolved: {0}")]
53    UnknownPeer(String),
54
55    #[error("missing channel between {0} and {1}")]
56    MissingChannel(String, String),
57
58    #[error("channel between {0} and {1} is not opened")]
59    ChannelNotOpened(String, String),
60
61    #[error("path contains loop on {0}")]
62    LoopsNotAllowed(String),
63
64    #[error("cannot find {0} hop path {1} -> {2} in the channel graph")]
65    PathNotFound(usize, String, String),
66
67    #[error(transparent)]
68    OtherError(#[from] GeneralError),
69}
70
71pub type Result<T> = core::result::Result<T, CoreTypesError>;