hopr_chain_actions/
errors.rs

1use hopr_chain_rpc::errors::RpcError;
2use hopr_internal_types::prelude::CoreTypesError;
3use hopr_primitive_types::errors::GeneralError;
4use thiserror::Error;
5
6/// Enumerates all Chain Actions related errors.
7#[derive(Debug, Error)]
8pub enum ChainActionsError {
9    #[error("channel is already opened")]
10    ChannelAlreadyExists,
11
12    #[error("channel does not exist")]
13    ChannelDoesNotExist,
14
15    #[error("channel is already closed")]
16    ChannelAlreadyClosed,
17
18    #[error("channel closure time has not elapsed yet, remaining {0}s")]
19    ClosureTimeHasNotElapsed(u64),
20
21    #[error("multiaddress has been already announced on-chain")]
22    AlreadyAnnounced,
23
24    #[error("network registry does not allow accessing this peer")]
25    PeerAccessDenied,
26
27    #[error("acknowledged {0} is in a wrong state for the operation")]
28    WrongTicketState(String),
29
30    #[error("given ticket has a superseded ticket index")]
31    OldTicket,
32
33    #[error("ticket is not a win")]
34    NotAWinningTicket,
35
36    #[error("balance is too low to perform the operation")]
37    BalanceTooLow,
38
39    #[error("channel stake is too low or too high")]
40    InvalidChannelStake,
41
42    #[error("safe does not have enough allowance to fund channel")]
43    NotEnoughAllowance,
44
45    #[error("on-chain submission of transaction failed: {0}")]
46    TransactionSubmissionFailed(String),
47
48    #[error("invalid argument: {0}")]
49    InvalidArguments(String),
50
51    #[error("invalid state: {0}")]
52    InvalidState(String),
53
54    #[error("timeout waiting for action confirmation")]
55    Timeout,
56
57    #[error("indexer expectation has been unregistered")]
58    ExpectationUnregistered,
59
60    #[error("no channel domain_separator tag found")]
61    MissingDomainSeparator,
62
63    #[error(transparent)]
64    DbBackendError(#[from] hopr_db_sql::errors::DbSqlError),
65
66    #[error(transparent)]
67    DbError(#[from] hopr_db_sql::api::errors::DbError),
68
69    #[error(transparent)]
70    RpcError(#[from] RpcError),
71
72    #[error(transparent)]
73    CoreTypesError(#[from] CoreTypesError),
74
75    #[error(transparent)]
76    GeneralError(#[from] GeneralError),
77}
78
79pub type Result<T> = std::result::Result<T, ChainActionsError>;