|
15 | 15 | // See the License for the specific language governing permissions and |
16 | 16 | // limitations under the License. |
17 | 17 |
|
18 | | -//! Error types in Consensus |
19 | | -use sp_core::ed25519::Public; |
20 | | -use sp_version::RuntimeVersion; |
21 | | -use std::error; |
| 18 | +//! Error types for consensus modules. |
22 | 19 |
|
23 | 20 | /// Result type alias. |
24 | 21 | pub type Result<T> = std::result::Result<T, Error>; |
25 | 22 |
|
26 | | -/// Error type. |
| 23 | +/// The error type for consensus-related operations. |
27 | 24 | #[derive(Debug, thiserror::Error)] |
28 | | -#[non_exhaustive] |
29 | 25 | pub enum Error { |
30 | 26 | /// Missing state at block with given descriptor. |
31 | 27 | #[error("State unavailable at block {0}")] |
32 | 28 | StateUnavailable(String), |
33 | | - /// I/O terminated unexpectedly |
34 | | - #[error("I/O terminated unexpectedly.")] |
35 | | - IoTerminated, |
36 | 29 | /// Intermediate missing. |
37 | | - #[error("Missing intermediate.")] |
| 30 | + #[error("Missing intermediate")] |
38 | 31 | NoIntermediate, |
39 | 32 | /// Intermediate is of wrong type. |
40 | | - #[error("Invalid intermediate.")] |
| 33 | + #[error("Invalid intermediate")] |
41 | 34 | InvalidIntermediate, |
42 | | - /// Unable to schedule wake-up. |
43 | | - #[error("Timer error: {0}")] |
44 | | - FaultyTimer(#[from] std::io::Error), |
45 | | - /// Error while working with inherent data. |
46 | | - #[error("InherentData error: {0}")] |
47 | | - InherentData(#[from] sp_inherents::Error), |
48 | | - /// Unable to propose a block. |
49 | | - #[error("Unable to create block proposal.")] |
50 | | - CannotPropose, |
51 | | - /// Error checking signature |
52 | | - #[error("Message signature {0:?} by {1:?} is invalid.")] |
| 35 | + /// Error checking signature. |
| 36 | + #[error("Message signature {0:?} by {1:?} is invalid")] |
53 | 37 | InvalidSignature(Vec<u8>, Vec<u8>), |
54 | 38 | /// Invalid authorities set received from the runtime. |
55 | 39 | #[error("Current state of blockchain has invalid authorities set")] |
56 | 40 | InvalidAuthoritiesSet, |
57 | | - /// Account is not an authority. |
58 | | - #[error("Message sender {0:?} is not a valid authority")] |
59 | | - InvalidAuthority(Public), |
60 | | - /// Authoring interface does not match the runtime. |
61 | | - #[error( |
62 | | - "Authoring for current \ |
63 | | - runtime is not supported. Native ({native}) cannot author for on-chain ({on_chain})." |
64 | | - )] |
65 | | - IncompatibleAuthoringRuntime { native: RuntimeVersion, on_chain: RuntimeVersion }, |
66 | | - /// Authoring interface does not match the runtime. |
67 | | - #[error("Authoring for current runtime is not supported since it has no version.")] |
68 | | - RuntimeVersionMissing, |
69 | | - /// Authoring interface does not match the runtime. |
70 | | - #[error("Authoring in current build is not supported since it has no runtime.")] |
71 | | - NativeRuntimeMissing, |
72 | 41 | /// Justification requirements not met. |
73 | | - #[error("Invalid justification.")] |
| 42 | + #[error("Invalid justification")] |
74 | 43 | InvalidJustification, |
75 | | - /// Some other error. |
76 | | - #[error(transparent)] |
77 | | - Other(#[from] Box<dyn error::Error + Sync + Send + 'static>), |
78 | | - /// Error from the client while importing |
| 44 | + /// Error from the client while importing. |
79 | 45 | #[error("Import failed: {0}")] |
80 | 46 | ClientImport(String), |
81 | | - /// Error from the client while importing |
| 47 | + /// Error from the client while fetching some data from the chain. |
82 | 48 | #[error("Chain lookup failed: {0}")] |
83 | 49 | ChainLookup(String), |
84 | | - /// Signing failed |
| 50 | + /// Signing failed. |
85 | 51 | #[error("Failed to sign using key: {0:?}. Reason: {1}")] |
86 | 52 | CannotSign(Vec<u8>, String), |
87 | | -} |
88 | | - |
89 | | -impl From<Public> for Error { |
90 | | - fn from(p: Public) -> Self { |
91 | | - Self::InvalidAuthority(p) |
92 | | - } |
93 | | -} |
94 | | - |
95 | | -impl From<String> for Error { |
96 | | - fn from(s: String) -> Self { |
97 | | - Self::StateUnavailable(s) |
98 | | - } |
| 53 | + /// Some other error. |
| 54 | + #[error(transparent)] |
| 55 | + Other(#[from] Box<dyn std::error::Error + Sync + Send + 'static>), |
99 | 56 | } |
0 commit comments