sc_consensus_beefy/
error.rs1use sp_blockchain::Error as ClientError;
24use std::fmt::Debug;
25
26#[derive(Debug, thiserror::Error)]
27pub enum Error {
28 #[error("Backend: {0}")]
29 Backend(String),
30 #[error("Keystore error: {0}")]
31 Keystore(String),
32 #[error("Runtime api error: {0}")]
33 RuntimeApi(sp_api::ApiError),
34 #[error("Signature error: {0}")]
35 Signature(String),
36 #[error("Session uninitialized")]
37 UninitSession,
38 #[error("pallet-beefy was reset")]
39 ConsensusReset,
40 #[error("Block import stream terminated")]
41 BlockImportStreamTerminated,
42 #[error("Gossip Engine terminated")]
43 GossipEngineTerminated,
44 #[error("Finality proofs gossiping stream terminated")]
45 FinalityProofGossipStreamTerminated,
46 #[error("Finality stream terminated")]
47 FinalityStreamTerminated,
48 #[error("Votes gossiping stream terminated")]
49 VotesGossipStreamTerminated,
50}
51
52impl From<ClientError> for Error {
53 fn from(e: ClientError) -> Self {
54 Self::Backend(e.to_string())
55 }
56}
57
58#[cfg(test)]
59impl PartialEq for Error {
60 fn eq(&self, other: &Self) -> bool {
61 match (self, other) {
62 (Error::Backend(s1), Error::Backend(s2)) => s1 == s2,
63 (Error::Keystore(s1), Error::Keystore(s2)) => s1 == s2,
64 (Error::RuntimeApi(_), Error::RuntimeApi(_)) => true,
65 (Error::Signature(s1), Error::Signature(s2)) => s1 == s2,
66 (Error::UninitSession, Error::UninitSession) => true,
67 (Error::ConsensusReset, Error::ConsensusReset) => true,
68 _ => false,
69 }
70 }
71}