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("acknowledged {0} is in a wrong state for the operation")]
25    WrongTicketState(String),
26
27    #[error("given ticket has a superseded ticket index")]
28    OldTicket,
29
30    #[error("balance is too low to perform the operation")]
31    BalanceTooLow,
32
33    #[error("channel stake is too low or too high")]
34    InvalidChannelStake,
35
36    #[error("safe does not have enough allowance to fund channel")]
37    NotEnoughAllowance,
38
39    #[error("domain separator is missing")]
40    MissingDomainSeparator,
41
42    #[error("on-chain submission of transaction failed: {0}")]
43    TransactionSubmissionFailed(String),
44
45    #[error("invalid argument: {0}")]
46    InvalidArguments(String),
47
48    #[error("invalid state: {0}")]
49    InvalidState(String),
50
51    #[error("timeout waiting for action confirmation")]
52    Timeout,
53
54    #[error("indexer expectation has been unregistered")]
55    ExpectationUnregistered,
56
57    #[error("node db error: {0}")]
58    NodeDbError(Box<dyn std::error::Error + Send + Sync>),
59
60    #[error(transparent)]
61    IndexDbError(#[from] hopr_db_sql::errors::DbSqlError),
62
63    #[error(transparent)]
64    RpcError(#[from] RpcError),
65
66    #[error(transparent)]
67    CoreTypesError(#[from] CoreTypesError),
68
69    #[error(transparent)]
70    GeneralError(#[from] GeneralError),
71}
72
73pub type Result<T> = std::result::Result<T, ChainActionsError>;