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
75
// Copyright 2020-2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use bee_message::{payload::milestone::MilestoneId, Error as MessageError};

/// Errors related to ledger types.
#[derive(Debug, thiserror::Error)]
pub enum Error {
    /// I/O error.
    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),
    /// Message error.
    #[error("Message error: {0}")]
    Message(#[from] MessageError),
    /// Unsupported output kind.
    #[error("Unsupported output kind: {0}")]
    UnsupportedOutputKind(u8),
    /// Unsupported input kind.
    #[error("Unsupported input kind: {0}")]
    UnsupportedInputKind(u8),
    /// Unsupported payload kind.
    #[error("Unsupported payload kind: {0}")]
    UnsupportedPayloadKind(u32),
    /// Invalid payload kind.
    #[error("Invalid payload kind: {0}")]
    InvalidPayloadKind(u32),
    /// Treasury amount mismatch.
    #[error("Treasury amount mismatch: {0} != {1}")]
    TreasuryAmountMismatch(u64, u64),
    /// Migrated funds amount overflow.
    #[error("Migrated funds amount overflow: {0}")]
    MigratedFundsAmountOverflow(u128),
    /// Invalid migrated funds amount.
    #[error("Invalid migrated funds amount: {0}")]
    InvalidMigratedFundsAmount(u64),
    /// Consumed treasury output mismatch.
    #[error("Consumed treasury output mismatch: {0} != {1}")]
    ConsumedTreasuryOutputMismatch(MilestoneId, MilestoneId),
    /// Negative balance.
    #[error("Negative balance: {0}")]
    NegativeBalance(i64),
    /// Negative dust allowance.
    #[error("Negative dust allowance: {0}")]
    NegativeDustAllowance(i64),
    /// Negative dust outputs.
    #[error("Negative dust outputs: {0}")]
    NegativeDustOutputs(i64),
    /// Balance overflow.
    #[error("Balance overflow: {0}")]
    BalanceOverflow(i128),
    /// Invalid balance.
    #[error("Invalid balance: {0}")]
    InvalidBalance(u64),
    /// Balance diff overflow.
    #[error("Balance diff overflow: {0}")]
    BalanceDiffOverflow(i128),
    /// Invalid balance diff.
    #[error("Invalid balance diff: {0}")]
    InvalidBalanceDiff(i64),
    /// Packable option error happened.
    #[error("Packable option error happened")]
    PackableOption,
    /// Invalid snapshot kind.
    #[error("Invalid snapshot kind: {0}")]
    InvalidSnapshotKind(u8),
    /// Unsupported snapshot version.
    #[error("Unsupported snapshot version: supports {0}, read {1}")]
    UnsupportedVersion(u8, u8),
    /// Missing consumed treasury.
    #[error("Missing consumed treasury")]
    MissingConsumedTreasury,
    /// Milestone length mismatch.
    #[error("Milestone length mismatch: expected {0}, got {1}")]
    MilestoneLengthMismatch(usize, usize),
}