hopr_crypto_packet/
errors.rs1use std::fmt::{Debug, Display, Formatter};
2
3use hopr_crypto_types::errors::CryptoError;
4use hopr_internal_types::{errors::CoreTypesError, prelude::Ticket};
5use hopr_primitive_types::errors::GeneralError;
6use thiserror::Error;
7
8#[derive(Error, Debug)]
9pub enum PacketError {
10 #[error("failed to decode packet: {0}")]
11 PacketDecodingError(String),
12
13 #[error("failed to construct packet: {0}")]
14 PacketConstructionError(String),
15
16 #[error("Proof of Relay challenge could not be verified")]
17 PoRVerificationError,
18
19 #[error("logic error during packet processing: {0}")]
20 LogicError(String),
21
22 #[error("underlying transport error while sending packet: {0}")]
23 TransportError(String),
24
25 #[error(transparent)]
26 CryptographicError(#[from] CryptoError),
27
28 #[error(transparent)]
29 CoreTypesError(#[from] CoreTypesError),
30
31 #[error(transparent)]
32 SphinxError(#[from] hopr_crypto_sphinx::errors::SphinxError),
33
34 #[error(transparent)]
35 Other(#[from] GeneralError),
36}
37
38pub type Result<T> = std::result::Result<T, PacketError>;
39
40#[derive(Debug, Clone)]
42pub struct TicketValidationError {
43 pub reason: String,
45 pub ticket: Box<Ticket>,
47}
48
49impl Display for TicketValidationError {
50 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
51 write!(f, "{}", self.reason)
52 }
53}
54
55impl std::error::Error for TicketValidationError {}