hopr_chain_actions/
errors.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use thiserror::Error;

use hopr_chain_rpc::errors::RpcError;
use hopr_internal_types::prelude::CoreTypesError;
use hopr_primitive_types::errors::GeneralError;

/// Enumerates all Chain Actions related errors.
#[derive(Debug, Error)]
pub enum ChainActionsError {
    #[error("channel is already opened")]
    ChannelAlreadyExists,

    #[error("channel does not exist")]
    ChannelDoesNotExist,

    #[error("channel is already closed")]
    ChannelAlreadyClosed,

    #[error("channel closure time has not elapsed yet, remaining {0}s")]
    ClosureTimeHasNotElapsed(u64),

    #[error("multiaddress has been already announced on-chain")]
    AlreadyAnnounced,

    #[error("network registry does not allow accessing this peer")]
    PeerAccessDenied,

    #[error("acknowledged {0} is in a wrong state for the operation")]
    WrongTicketState(String),

    #[error("given ticket has a superseded ticket index")]
    OldTicket,

    #[error("ticket is not a win")]
    NotAWinningTicket,

    #[error("balance is too low to perform the operation")]
    BalanceTooLow,

    #[error("safe does not have enough allowance to fund channel")]
    NotEnoughAllowance,

    #[error("on-chain submission of transaction failed: {0}")]
    TransactionSubmissionFailed(String),

    #[error("invalid argument: {0}")]
    InvalidArguments(String),

    #[error("invalid state: {0}")]
    InvalidState(String),

    #[error("timeout waiting for action confirmation")]
    Timeout,

    #[error("indexer expectation has been unregistered")]
    ExpectationUnregistered,

    #[error("no channel domain_separator tag found")]
    MissingDomainSeparator,

    #[error(transparent)]
    DbBackendError(#[from] hopr_db_sql::errors::DbSqlError),

    #[error(transparent)]
    DbError(#[from] hopr_db_sql::api::errors::DbError),

    #[error(transparent)]
    RpcError(#[from] RpcError),

    #[error(transparent)]
    CoreTypesError(#[from] CoreTypesError),

    #[error(transparent)]
    GeneralError(#[from] GeneralError),
}

pub type Result<T> = std::result::Result<T, ChainActionsError>;