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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
use sp_version::RuntimeVersion;
use sp_core::ed25519::Public;
use std::error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, derive_more::Display, derive_more::From)]
pub enum Error {
#[display(fmt="State unavailable at block {}", _0)]
StateUnavailable(String),
#[display(fmt="I/O terminated unexpectedly.")]
IoTerminated,
#[display(fmt="Missing intermediate.")]
NoIntermediate,
#[display(fmt="Invalid intermediate.")]
InvalidIntermediate,
#[display(fmt="Timer error: {}", _0)]
FaultyTimer(std::io::Error),
#[display(fmt="InherentData error: {}", _0)]
InherentData(sp_inherents::Error),
#[display(fmt="Unable to create block proposal.")]
CannotPropose,
#[display(fmt="Message signature {:?} by {:?} is invalid.", _0, _1)]
InvalidSignature(Vec<u8>, Vec<u8>),
#[display(fmt="Current state of blockchain has invalid authorities set")]
InvalidAuthoritiesSet,
#[display(fmt="Message sender {:?} is not a valid authority.", _0)]
InvalidAuthority(Public),
#[display(fmt="Authoring for current \
runtime is not supported. Native ({}) cannot author for on-chain ({}).", native, on_chain)]
IncompatibleAuthoringRuntime { native: RuntimeVersion, on_chain: RuntimeVersion },
#[display(fmt="Authoring for current runtime is not supported since it has no version.")]
RuntimeVersionMissing,
#[display(fmt="Authoring in current build is not supported since it has no runtime.")]
NativeRuntimeMissing,
#[display(fmt="Invalid justification.")]
InvalidJustification,
#[display(fmt="Other error: {}", _0)]
Other(Box<dyn error::Error + Send>),
#[display(fmt="Import failed: {}", _0)]
#[from(ignore)]
ClientImport(String),
#[display(fmt="Chain lookup failed: {}", _0)]
#[from(ignore)]
ChainLookup(String),
#[display(fmt="Failed to sign using key: {:?}. Reason: {}", _0, _1)]
CannotSign(Vec<u8>, String)
}
impl error::Error for Error {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match self {
Error::FaultyTimer(ref err) => Some(err),
Error::Other(ref err) => Some(&**err),
_ => None,
}
}
}