ic_memory/ledger/
error.rs1use crate::{key::StableKey, physical::CommitRecoveryError, slot::MemoryManagerSlot};
2
3#[non_exhaustive]
10#[derive(Clone, Debug, Eq, thiserror::Error, PartialEq)]
11pub enum LedgerIntegrityError {
12 #[error("ledger exceeds {resource} limit {limit}")]
14 LimitExceeded {
15 resource: &'static str,
16 limit: usize,
17 },
18 #[error("stable key '{stable_key}' appears in more than one allocation record")]
20 DuplicateStableKey { stable_key: StableKey },
21 #[error("allocation slot '{slot:?}' appears in more than one allocation record")]
23 DuplicateSlot { slot: MemoryManagerSlot },
24 #[error("genesis ledger contains allocation records")]
26 NonemptyGenesis,
27}
28
29#[non_exhaustive]
37#[derive(Clone, Debug, Eq, thiserror::Error, PartialEq)]
38pub enum LedgerDecodeError {
39 #[error(transparent)]
41 Wire(#[from] ic_wire::Error),
42 #[error(transparent)]
44 Key(#[from] crate::StableKeyError),
45 #[error(transparent)]
47 Slot(#[from] crate::MemoryManagerSlotError),
48}
49
50#[non_exhaustive]
55#[derive(Clone, Debug, Eq, thiserror::Error, PartialEq)]
56pub enum LedgerCommitError {
57 #[error(transparent)]
59 Recovery(CommitRecoveryError),
60 #[error("allocation ledger codec failed: {0}")]
62 Codec(#[source] LedgerDecodeError),
63 #[error(transparent)]
65 Integrity(LedgerIntegrityError),
66}
67
68#[non_exhaustive]
75#[derive(Clone, Debug, Eq, thiserror::Error, PartialEq)]
76pub enum AllocationStageError {
77 #[error("ledger generation {generation} cannot be advanced without overflow")]
79 GenerationOverflow { generation: u64 },
80 #[error(transparent)]
81 Integrity(#[from] LedgerIntegrityError),
82}