1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright (c) 2022 MASSA LABS <info@massa.net>
use displaydoc::Display;
use massa_execution_exports::ExecutionError;
use massa_models::error::ModelsError;
use massa_protocol_exports::ProtocolError;
use massa_time::TimeError;
use std::array::TryFromSliceError;
use thiserror::Error;

/// Consensus error
#[non_exhaustive]
#[derive(Display, Error, Debug)]
pub enum ConsensusError {
    /// execution error: {0}
    ExecutionError(#[from] ExecutionError),
    /// models error: {0}
    ModelsError(#[from] ModelsError),
    /// Serialization error: {0}
    SerializationError(String),
    /// Could not create genesis block {0}
    GenesisCreationError(String),
    /// missing block {0}
    MissingBlock(String),
    /// missing operation {0}
    MissingOperation(String),
    /// there was an inconsistency between containers {0}
    ContainerInconsistency(String),
    /// fitness overflow
    FitnessOverflow,
    /// invalid ledger change: {0}
    InvalidLedgerChange(String),
    /// io error {0}
    IOError(#[from] std::io::Error),
    /// serde error
    SerdeError(#[from] serde_json::Error),
    /// Proof of stake cycle unavailable {0}
    PosCycleUnavailable(String),
    /// Ledger error {0}
    LedgerError(#[from] LedgerError),
    /// Massa time error {0}
    MassaTimeError(#[from] TimeError),
    /// transaction error {0}
    TransactionError(String),
    /// Protocol error {0}
    ProtocolError(#[from] ProtocolError),
    /// Invalid transition {0}
    InvalidTransition(String),
}

/// Internal error
#[non_exhaustive]
#[derive(Display, Error, Debug)]
pub enum InternalError {
    /// transaction error {0}
    TransactionError(String),
}

/// Ledger error
#[non_exhaustive]
#[derive(Display, Error, Debug)]
pub enum LedgerError {
    /// amount overflow
    AmountOverflowError,
    /// ledger inconsistency error {0}
    LedgerInconsistency(String),
    /// models error: {0}
    ModelsError(#[from] ModelsError),
    /// try from slice error {0}
    TryFromSliceError(#[from] TryFromSliceError),
    /// io error {0}
    IOError(#[from] std::io::Error),
    /// serde error
    SerdeError(#[from] serde_json::Error),
}