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
use super::config::Alias;
use crate::{FragmentSenderError, FragmentVerifierError};
use chain_crypto::SecretKeyError;
use chain_impl_mockchain::{accounting::account::spending, fragment::FragmentId};
use jormungandr_automation::jormungandr::RestError;
use jormungandr_lib::crypto::account::SigningKeyParseError;
use thiserror::Error;
#[derive(Debug, Error)]
#[allow(clippy::large_enum_variant)]
pub enum Error {
    #[error(transparent)]
    FragmentVerifier(#[from] FragmentVerifierError),
    #[error(transparent)]
    FragmentSender(#[from] FragmentSenderError),
    #[error(transparent)]
    Bech32(#[from] bech32::Error),
    #[error(transparent)]
    SecretKey(#[from] SecretKeyError),
    #[error("cannot connect to backend under address: {0}, due to: {1:?}")]
    Connection(String, RestError),
    #[error(transparent)]
    SigningKeyParse(#[from] SigningKeyParseError),
    #[error(transparent)]
    Io(#[from] std::io::Error),
    #[error(transparent)]
    Serde(#[from] serde_yaml::Error),
    #[error(transparent)]
    Config(#[from] crate::cli::config::Error),
    #[error("cannot serialize secret key")]
    CannotrSerializeSecretKey,
    #[error(transparent)]
    SpendingCounterError(#[from] spending::Error),
    #[error("cannot read secret key")]
    CannotReadSecretKey,
    #[error("unknown alias: '{0}'")]
    UknownAlias(Alias),
    #[error("no default alias specified")]
    NoDefaultAliasDefined,
    #[error("cannot read/write secret key")]
    Cocoon,
    #[error("Bincode error")]
    Bincode,
    #[error(transparent)]
    Key(#[from] jcli_lib::key::Error),

    #[error("cannot find proposal: voteplan({vote_plan_name}) index({proposal_index})")]
    CannotFindProposal {
        vote_plan_name: String,
        proposal_index: u32,
    },
    #[error("transactions with ids [{fragments:?}] were pending for too long")]
    TransactionsWerePendingForTooLong { fragments: Vec<FragmentId> },
    #[error(transparent)]
    Rest(#[from] RestError),
}

impl From<cocoon::Error> for Error {
    fn from(_err: cocoon::Error) -> Self {
        Error::Cocoon
    }
}