hopr_protocol_hopr/
errors.rs1use hopr_api::Address;
2use hopr_crypto_packet::errors::TicketValidationError;
3use hopr_crypto_types::{prelude::HalfKeyChallenge, types::OffchainPublicKey};
4use hopr_internal_types::prelude::ChannelId;
5use hopr_primitive_types::balance::HoprBalance;
6use thiserror::Error;
7
8#[derive(Debug, strum::EnumIs, strum::EnumTryAs, Error)]
10pub enum IncomingPacketError<E: std::error::Error> {
11 #[error("packet is not decodable: {0}")]
15 Undecodable(E),
16 #[error("local overload: {0}")]
18 Overloaded(E),
19 #[error("packet from {0} decodable, but cannot be processed: {1}")]
23 ProcessingError(OffchainPublicKey, E),
24 #[error("packet from {0} is decodable, but the ticket is invalid: {1}")]
26 InvalidTicket(OffchainPublicKey, TicketValidationError),
27}
28
29#[derive(Debug, strum::EnumIs, strum::EnumTryAs, Error)]
31pub enum TicketCreationError<E: std::error::Error> {
32 #[error("channel {0} does not have at least {1} to create a ticket")]
33 OutOfFunds(ChannelId, HoprBalance),
34 #[error("could not create ticket: {0}")]
35 Other(E),
36}
37
38#[derive(Error, Debug)]
39pub enum HoprProtocolError {
40 #[error("packet is in invalid state: {0}")]
41 InvalidState(&'static str),
42
43 #[error("cannot decode the sender address of the packet")]
44 InvalidSender,
45
46 #[error("failed to resolve chain key or packet key")]
47 KeyNotFound,
48
49 #[error("channel {0} does not have at least {1} to create a ticket")]
50 OutOfFunds(ChannelId, HoprBalance),
51
52 #[error("packet replay detected")]
53 Replay,
54
55 #[error("failed to find channel {0} -> {1}")]
56 ChannelNotFound(Address, Address),
57
58 #[error("could not find unacknowledged ticket for challenge {0}")]
59 UnacknowledgedTicketNotFound(HalfKeyChallenge),
60
61 #[error("chain resolver error: {0}")]
62 ResolverError(#[source] anyhow::Error),
63
64 #[error("ticket tracker error: {0}")]
65 TicketTrackerError(#[source] anyhow::Error),
66
67 #[error(transparent)]
68 TicketValidationError(#[from] TicketValidationError),
69
70 #[error(transparent)]
71 CoreTypesError(#[from] hopr_internal_types::errors::CoreTypesError),
72
73 #[error(transparent)]
74 PacketError(#[from] hopr_crypto_packet::errors::PacketError),
75
76 #[error(transparent)]
77 GeneralError(#[from] hopr_primitive_types::errors::GeneralError),
78
79 #[error("rayon thread pool queue full: {0}")]
80 SpawnError(#[from] hopr_parallelize::cpu::SpawnError),
81}