ic_memory/runtime/
error.rs1use crate::{
2 LedgerCommitError, PolicyIdentity, StableCellLedgerError, requests::MemoryDeclarationError,
3};
4
5#[non_exhaustive]
14#[derive(Clone, Copy, Debug, Eq, thiserror::Error, PartialEq)]
15pub enum RuntimeGrowError {
16 #[error(transparent)]
18 Layout(#[from] super::MemoryManagerLayoutError),
19 #[error("virtual memory page count overflows")]
21 ArithmeticOverflow,
22 #[error("growth requires {required_buckets} buckets, exceeding capacity {capacity}")]
24 BucketExhausted {
25 required_buckets: u64,
26 capacity: u16,
27 },
28 #[error("backing memory refused growth by {additional_pages} pages")]
30 BackingRefused { additional_pages: u64 },
31 #[error("runtime memory growth is already in progress")]
33 ReentrantAccess,
34}
35
36#[non_exhaustive]
44#[derive(Clone, Copy, Debug, Eq, thiserror::Error, PartialEq)]
45pub enum RuntimeConstructionError {
46 #[error("stable backing already has a live runtime or allocation handle")]
48 BackingAlreadyClaimed,
49 #[error(transparent)]
51 Growth(#[from] RuntimeGrowError),
52 #[error("bucket size must be nonzero")]
54 InvalidBucketSize,
55 #[error("persisted bucket size {persisted} pages differs from requested {requested}")]
57 BucketSizeMismatch { persisted: u16, requested: u16 },
58 #[error(transparent)]
60 Layout(#[from] super::MemoryManagerLayoutError),
61 #[error(
63 "nonempty backing memory is not an ic-stable-structures MemoryManager \
64 (expected magic 'MGR', found bytes {observed_magic:?})"
65 )]
66 ForeignMemory {
67 observed_magic: [u8; 3],
69 },
70 #[error(
72 "unsupported ic-stable-structures MemoryManager layout version {observed}; \
73 expected {supported}"
74 )]
75 UnsupportedMemoryManagerVersion {
76 observed: u8,
78 supported: u8,
80 },
81}
82
83#[non_exhaustive]
90#[derive(Debug, thiserror::Error)]
91pub enum RuntimeBootstrapError<P> {
92 #[error(transparent)]
94 ManagerLayout(#[from] super::MemoryManagerLayoutError),
95 #[error("ic-memory runtime has not completed bootstrap validation")]
97 NotBootstrapped,
98 #[error(transparent)]
100 Admission(#[from] super::BootstrapAdmissionError),
101 #[error("bootstrap admission policy rejected recovered allocation metadata")]
103 AdmissionPolicy(P),
104 #[error(transparent)]
105 Resolution(#[from] MemoryResolutionError),
106 #[error("runtime bootstrap declaration snapshot differs from the established binding")]
108 DeclarationSnapshotMismatch,
109 #[error("runtime allocation pool differs from the established host policy")]
111 AllocationPoolMismatch,
112 #[error("runtime bootstrap policy identity changed from {established:?} to {requested:?}")]
114 PolicyIdentityMismatch {
115 established: PolicyIdentity,
117 requested: PolicyIdentity,
119 },
120 #[error(transparent)]
122 LedgerCommit(#[from] crate::LedgerCommitError),
123 #[error(transparent)]
125 StableCellLedger(#[from] StableCellLedgerError),
126 #[error("stable-cell ledger record size {value_size} cannot be written to stable memory")]
128 StableCellLedgerWriteTooLarge {
129 value_size: usize,
131 },
132 #[error(transparent)]
134 LedgerGrowth(#[from] RuntimeGrowError),
135 #[error(transparent)]
137 Validation(#[from] crate::AllocationValidationError<P>),
138 #[error(transparent)]
140 Staging(#[from] crate::AllocationStageError),
141}
142
143#[non_exhaustive]
150#[derive(Clone, Debug, Eq, thiserror::Error, PartialEq)]
151pub enum RuntimeOpenError {
152 #[error(transparent)]
154 Layout(#[from] super::MemoryManagerLayoutError),
155 #[error("MemoryManager ID {id} already has a live allocation lease")]
157 AlreadyOpen { id: u8 },
158 #[error("ic-memory runtime has not completed bootstrap validation")]
160 NotBootstrapped,
161 #[error(transparent)]
163 StableKey(#[from] crate::StableKeyError),
164 #[error("stable key '{0}' was not committed by ic-memory runtime bootstrap")]
166 StableKeyNotCommitted(String),
167 #[error("stable key '{stable_key}' is reserved for ic-memory runtime governance")]
169 ReservedStableKey {
170 stable_key: String,
172 },
173}
174
175#[non_exhaustive]
182#[derive(Debug, thiserror::Error)]
183pub enum RuntimeDiagnosticError {
184 #[error(transparent)]
186 Construction(#[from] RuntimeConstructionError),
187 #[error("ic-memory runtime has not completed bootstrap validation")]
189 NotBootstrapped,
190 #[error("runtime memory growth is already in progress")]
192 ReentrantAccess,
193 #[error(transparent)]
195 LedgerCommit(#[from] LedgerCommitError),
196 #[error(transparent)]
198 StableCellLedger(#[from] StableCellLedgerError),
199}
200
201#[non_exhaustive]
208#[derive(Debug, thiserror::Error)]
209pub enum MemoryResolutionError {
210 #[error("unmanaged MemoryManager ID {id} needs an explicit host exclusion")]
212 UnmanagedAllocation { id: u8 },
213 #[error("no eligible free slot for {stable_key} under authority {authority}")]
214 Exhausted {
215 stable_key: crate::StableKey,
216 authority: String,
217 },
218 #[error(transparent)]
219 Pool(#[from] crate::MemoryAllocationPoolError),
220 #[error(transparent)]
221 Declarations(#[from] MemoryDeclarationError),
222}