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]
34#[derive(Clone, Debug, Eq, thiserror::Error, PartialEq)]
35pub enum LedgerCommitError {
36 #[error(transparent)]
38 Recovery(CommitRecoveryError),
39 #[error(
41 "physical generation {physical_generation} does not match logical ledger generation {logical_generation}"
42 )]
43 PhysicalLogicalGenerationMismatch {
44 physical_generation: u64,
46 logical_generation: u64,
48 },
49 #[error("allocation ledger codec failed: {0}")]
51 Codec(String),
52 #[error(transparent)]
54 Integrity(LedgerIntegrityError),
55}
56
57#[non_exhaustive]
64#[derive(Clone, Debug, Eq, thiserror::Error, PartialEq)]
65pub enum AllocationStageError {
66 #[error("ledger generation {generation} cannot be advanced without overflow")]
68 GenerationOverflow { generation: u64 },
69 #[error(transparent)]
70 Integrity(#[from] LedgerIntegrityError),
71}