Skip to main content

dpp/errors/consensus/
consensus_error.rs

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