referrerpolicy=no-referrer-when-downgrade

polkadot_dispute_distribution/sender/
error.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Polkadot.
3
4// Polkadot is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Polkadot is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Polkadot.  If not, see <http://www.gnu.org/licenses/>.
16//
17
18//! Error handling related code and Error/Result definitions.
19
20use polkadot_node_primitives::disputes::DisputeMessageCheckError;
21use polkadot_node_subsystem::SubsystemError;
22use polkadot_node_subsystem_util::runtime;
23
24#[allow(missing_docs)]
25#[fatality::fatality(splitable)]
26pub enum Error {
27	#[fatal]
28	#[error("Spawning subsystem task failed")]
29	SpawnTask(#[source] SubsystemError),
30
31	#[fatal(forward)]
32	#[error("Error while accessing runtime information")]
33	Runtime(#[from] runtime::Error),
34
35	/// We need available active heads for finding relevant authorities.
36	#[error("No active heads available - needed for finding relevant authorities.")]
37	NoActiveHeads,
38
39	/// This error likely indicates a bug in the coordinator.
40	#[error("Oneshot for asking dispute coordinator for active disputes got canceled.")]
41	AskActiveDisputesCanceled,
42
43	/// This error likely indicates a bug in the coordinator.
44	#[error("Oneshot for asking dispute coordinator for candidate votes got canceled.")]
45	AskCandidateVotesCanceled,
46
47	/// This error does indicate a bug in the coordinator.
48	///
49	/// We were not able to successfully construct a `DisputeMessage` from disputes votes.
50	#[error("Invalid dispute encountered")]
51	InvalidDisputeFromCoordinator(#[source] DisputeMessageCheckError),
52
53	/// This error does indicate a bug in the coordinator.
54	///
55	/// We did not receive votes on both sides for `CandidateVotes` received from the coordinator.
56	#[error("Missing votes for valid dispute")]
57	MissingVotesFromCoordinator,
58
59	/// This error does indicate a bug in the coordinator.
60	///
61	/// `SignedDisputeStatement` could not be reconstructed from recorded statements.
62	#[error("Invalid statements from coordinator")]
63	InvalidStatementFromCoordinator,
64
65	/// This error does indicate a bug in the coordinator.
66	///
67	/// A statement's `ValidatorIndex` could not be looked up.
68	#[error("ValidatorIndex of statement could not be found")]
69	InvalidValidatorIndexFromCoordinator,
70}
71
72pub type Result<T> = std::result::Result<T, Error>;
73pub type JfyiErrorResult<T> = std::result::Result<T, JfyiError>;