hopr_ticket_manager/
errors.rs1use hopr_api::chain::{ChannelId, HoprBalance};
2
3#[derive(Debug, thiserror::Error)]
5pub enum TicketManagerError {
6 #[error("channel does not exist or no tickets were found")]
7 ChannelQueueNotFound,
8 #[error("already redeeming in this channel")]
9 AlreadyRedeeming,
10 #[error("balance of channel {0} is too low: {1}")]
11 OutOfFunds(ChannelId, HoprBalance),
12 #[error("ticket redemption error: {0}")]
13 RedeemError(#[source] anyhow::Error),
14 #[error("storage error: {0}")]
15 StoreError(#[source] anyhow::Error),
16 #[error(transparent)]
17 Other(anyhow::Error),
18}
19
20impl TicketManagerError {
21 pub fn redeem<E: Into<anyhow::Error>>(error: E) -> Self {
22 Self::RedeemError(error.into())
23 }
24
25 pub fn store<E: Into<anyhow::Error>>(error: E) -> Self {
26 Self::StoreError(error.into())
27 }
28}