Skip to main content

soil_client/consensus/
error.rs

1// This file is part of Soil.
2
3// Copyright (C) Soil contributors.
4// Copyright (C) Parity Technologies (UK) Ltd.
5// SPDX-License-Identifier: Apache-2.0 OR GPL-3.0-or-later WITH Classpath-exception-2.0
6
7//! Error types for consensus modules.
8
9/// Result type alias.
10pub type Result<T> = std::result::Result<T, Error>;
11
12/// The error type for consensus-related operations.
13#[derive(Debug, thiserror::Error)]
14pub enum Error {
15	/// Missing state at block with given descriptor.
16	#[error("State unavailable at block {0}")]
17	StateUnavailable(String),
18	/// Intermediate missing.
19	#[error("Missing intermediate")]
20	NoIntermediate,
21	/// Intermediate is of wrong type.
22	#[error("Invalid intermediate")]
23	InvalidIntermediate,
24	/// Error checking signature.
25	#[error("Message signature {0:?} by {1:?} is invalid")]
26	InvalidSignature(Vec<u8>, Vec<u8>),
27	/// Invalid authorities set received from the runtime.
28	#[error("Current state of blockchain has invalid authorities set")]
29	InvalidAuthoritiesSet,
30	/// Justification requirements not met.
31	#[error("Invalid justification")]
32	InvalidJustification,
33	/// The justification provided is outdated and corresponds to a previous set.
34	#[error("Import failed with outdated justification")]
35	OutdatedJustification,
36	/// Error from the client while importing.
37	#[error("Import failed: {0}")]
38	ClientImport(String),
39	/// Error from the client while fetching some data from the chain.
40	#[error("Chain lookup failed: {0}")]
41	ChainLookup(String),
42	/// Signing failed.
43	#[error("Failed to sign: {0}")]
44	CannotSign(String),
45	/// Some other error.
46	#[error(transparent)]
47	Other(#[from] Box<dyn std::error::Error + Sync + Send + 'static>),
48}