massa_consensus_exports/
error.rs

1// Copyright (c) 2022 MASSA LABS <info@massa.net>
2use displaydoc::Display;
3use massa_execution_exports::ExecutionError;
4use massa_models::error::ModelsError;
5use massa_protocol_exports::ProtocolError;
6use massa_time::TimeError;
7use std::array::TryFromSliceError;
8use thiserror::Error;
9
10/// Consensus error
11#[non_exhaustive]
12#[derive(Display, Error, Debug)]
13pub enum ConsensusError {
14    /// execution error: {0}
15    ExecutionError(#[from] ExecutionError),
16    /// models error: {0}
17    ModelsError(#[from] ModelsError),
18    /// Serialization error: {0}
19    SerializationError(String),
20    /// Could not create genesis block {0}
21    GenesisCreationError(String),
22    /// missing block {0}
23    MissingBlock(String),
24    /// missing operation {0}
25    MissingOperation(String),
26    /// there was an inconsistency between containers {0}
27    ContainerInconsistency(String),
28    /// fitness overflow
29    FitnessOverflow,
30    /// invalid ledger change: {0}
31    InvalidLedgerChange(String),
32    /// io error {0}
33    IOError(#[from] std::io::Error),
34    /// serde error
35    SerdeError(#[from] serde_json::Error),
36    /// Proof of stake cycle unavailable {0}
37    PosCycleUnavailable(String),
38    /// Ledger error {0}
39    LedgerError(#[from] LedgerError),
40    /// Massa time error {0}
41    MassaTimeError(#[from] TimeError),
42    /// transaction error {0}
43    TransactionError(String),
44    /// Protocol error {0}
45    ProtocolError(#[from] ProtocolError),
46    /// Invalid transition {0}
47    InvalidTransition(String),
48}
49
50/// Internal error
51#[non_exhaustive]
52#[derive(Display, Error, Debug)]
53pub enum InternalError {
54    /// transaction error {0}
55    TransactionError(String),
56}
57
58/// Ledger error
59#[non_exhaustive]
60#[derive(Display, Error, Debug)]
61pub enum LedgerError {
62    /// amount overflow
63    AmountOverflowError,
64    /// ledger inconsistency error {0}
65    LedgerInconsistency(String),
66    /// models error: {0}
67    ModelsError(#[from] ModelsError),
68    /// try from slice error {0}
69    TryFromSliceError(#[from] TryFromSliceError),
70    /// io error {0}
71    IOError(#[from] std::io::Error),
72    /// serde error
73    SerdeError(#[from] serde_json::Error),
74}