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
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 {
RegexError(regex::Error);
Secp256k1Error(secp256k1::Error);
}
errors {
SECP256k1 {
description("Misc SECP-256k1 Error")
display("Misc SECP-256K1 Error")
}
InvalidChecksum{
description("Key has an invalid checksum")
display("Invalid Checksum")
}
EncodeError{
description("Encoding Error")
display("Encoding Error")
}
InvalidPubKeyFormat {
description("Invalid public key format")
display("Invalid public key format")
}
InvalidPrivateKeyFormat{
description("The private key is not in a format we expect. PVT_(?P<type>[A-Za-z0-9]+)_(?P<key>[A-Za-z0-9]+)")
display("Invalid PrivateKey Format")
}
InvalidSignatureFormat{
description("Invalid signature format")
display("Invalid signature format")
}
InvalidSignatureChecksum{
description("Checksum for signature failed")
display("checksum for signature failed")
}
IncorrectSignature{
description("Signature is incorrect")
display("Signature is incorrect")
}
DecodeError(reason:String){
description("Failed to decode string into key")
display("Failed to decode string into key {}", reason)
}
}
}