sp_consensus/error.rs
1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18//! Error types for consensus modules.
19
20/// Result type alias.
21pub type Result<T> = std::result::Result<T, Error>;
22
23/// The error type for consensus-related operations.
24#[derive(Debug, thiserror::Error)]
25pub enum Error {
26 /// Missing state at block with given descriptor.
27 #[error("State unavailable at block {0}")]
28 StateUnavailable(String),
29 /// Intermediate missing.
30 #[error("Missing intermediate")]
31 NoIntermediate,
32 /// Intermediate is of wrong type.
33 #[error("Invalid intermediate")]
34 InvalidIntermediate,
35 /// Error checking signature.
36 #[error("Message signature {0:?} by {1:?} is invalid")]
37 InvalidSignature(Vec<u8>, Vec<u8>),
38 /// Invalid authorities set received from the runtime.
39 #[error("Current state of blockchain has invalid authorities set")]
40 InvalidAuthoritiesSet,
41 /// Justification requirements not met.
42 #[error("Invalid justification")]
43 InvalidJustification,
44 /// Error from the client while importing.
45 #[error("Import failed: {0}")]
46 ClientImport(String),
47 /// Error from the client while fetching some data from the chain.
48 #[error("Chain lookup failed: {0}")]
49 ChainLookup(String),
50 /// Signing failed.
51 #[error("Failed to sign: {0}")]
52 CannotSign(String),
53 /// Some other error.
54 #[error(transparent)]
55 Other(#[from] Box<dyn std::error::Error + Sync + Send + 'static>),
56}