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
#[allow(missing_docs)]
use error_chain::error_chain;

impl From<Box<dyn std::error::Error>> for Error {
    fn from(e: Box<dyn std::error::Error>) -> Self {
        Self::from(format!("{:?}", e))
    }
}

impl From<Box<dyn std::error::Error + Sync + Send>> for Error {
    fn from(e: Box<dyn std::error::Error + Sync + Send>) -> Self {
        Self::from(format!("{:?}", e))
    }
}

#[cfg(test)]
impl PartialEq for Error {
    fn eq(&self, _other: &Self) -> bool {
        false
    }
}
error_chain! {

    foreign_links {
    ReqwestError(::reqwest::Error);
    SerdeJsonError(serde_json::Error);

    HexError(hex::FromHexError);

    ParseIntError(std::num::ParseIntError);
    Secp256k1(bitcoin::secp256k1::Error);
    Bip32(bitcoin::util::bip32::Error);
    }
    errors {
        Terra(err:String) {
            description("Terra CLI Error")
            display("Terra CLI: {}" ,err)
        }
        Bech32DecodeErr {
            description("Bech32 Address Decode Error")
            display("Bech32 Address Decode Error")
        }
        Phrasing {
           description("Mnemonic - Bad Phrase")
           display("Mnemonic - Bad Phrase")
        }
        Implementation {
            description("Bad Implementation. Missing Component")
            display("Bad Implementation. Missing Component")
        }
        Conversion(err:String) {
            description("Unable to convert into public key")
            display("Unable to convert into public key {}",err)
        }
        NoGasOpts {
            description("Can't call Transactions without some gas rules")
            display("Can't call transactions without some gas rules")
        }
    }
}