dpp/errors/consensus/
consensus_error.rs

1use crate::errors::ProtocolError;
2use bincode;
3use bincode::{Decode, Encode};
4use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize};
5
6use crate::consensus::state::state_error::StateError;
7
8use crate::consensus::fee::fee_error::FeeError;
9use crate::consensus::signature::SignatureError;
10
11#[cfg(test)]
12use crate::consensus::test_consensus_error::TestConsensusError;
13
14use crate::errors::consensus::basic::BasicError;
15
16// TODO It must be versioned as all other serializable types
17
18#[derive(
19    thiserror::Error,
20    Debug,
21    Encode,
22    Decode,
23    PlatformSerialize,
24    PlatformDeserialize,
25    Clone,
26    PartialEq,
27)]
28#[platform_serialize(limit = 2000)]
29#[error(transparent)]
30#[allow(clippy::large_enum_variant)]
31pub enum ConsensusError {
32    /*
33
34    DO NOT CHANGE ORDER OF VARIANTS WITHOUT INTRODUCING OF NEW VERSION
35
36    */
37    #[error("default error")]
38    DefaultError,
39
40    #[error(transparent)]
41    BasicError(BasicError),
42
43    #[error(transparent)]
44    StateError(StateError),
45
46    #[error(transparent)]
47    SignatureError(SignatureError),
48
49    #[error(transparent)]
50    FeeError(FeeError),
51
52    #[cfg(test)]
53    #[cfg_attr(test, error(transparent))]
54    TestConsensusError(TestConsensusError),
55}
56
57#[cfg(test)]
58impl From<TestConsensusError> for ConsensusError {
59    fn from(error: TestConsensusError) -> Self {
60        Self::TestConsensusError(error)
61    }
62}