ic_memory/runtime/
error.rs1use crate::{
2 LedgerCommitError, PolicyIdentity, PolicyIdentityError, StableCellLedgerError,
3 requests::MemoryDeclarationError,
4};
5
6#[non_exhaustive]
15#[derive(Clone, Copy, Debug, Eq, thiserror::Error, PartialEq)]
16pub enum RuntimeGrowError {
17 #[error("virtual memory page count overflows")]
19 ArithmeticOverflow,
20 #[error("growth requires {required_buckets} buckets, exceeding capacity {capacity}")]
22 BucketExhausted {
23 required_buckets: u64,
24 capacity: u16,
25 },
26 #[error("backing memory refused growth by {additional_pages} pages")]
28 BackingRefused { additional_pages: u64 },
29 #[error("runtime memory growth is already in progress")]
31 ReentrantAccess,
32}
33
34#[non_exhaustive]
42#[derive(Clone, Copy, Debug, Eq, thiserror::Error, PartialEq)]
43pub enum RuntimeConstructionError {
44 #[error(transparent)]
46 Growth(#[from] RuntimeGrowError),
47 #[error("bucket size must be nonzero")]
49 InvalidBucketSize,
50 #[error("persisted bucket size {persisted} pages differs from requested {requested}")]
52 BucketSizeMismatch { persisted: u16, requested: u16 },
53 #[error(transparent)]
55 Layout(#[from] super::MemoryManagerLayoutError),
56 #[error(
58 "nonempty backing memory is not an ic-stable-structures MemoryManager \
59 (expected magic 'MGR', found bytes {observed_magic:?})"
60 )]
61 ForeignMemory {
62 observed_magic: [u8; 3],
64 },
65 #[error(
67 "unsupported ic-stable-structures MemoryManager layout version {observed}; \
68 expected {supported}"
69 )]
70 UnsupportedMemoryManagerVersion {
71 observed: u8,
73 supported: u8,
75 },
76}
77
78#[non_exhaustive]
85#[derive(Debug, thiserror::Error)]
86pub enum RuntimeBootstrapError<P> {
87 #[error(transparent)]
89 Admission(#[from] super::BootstrapAdmissionError),
90 #[error("bootstrap admission policy rejected recovered allocation metadata")]
92 AdmissionPolicy(P),
93 #[error(transparent)]
94 Resolution(#[from] MemoryResolutionError),
95 #[error(transparent)]
97 PolicyIdentity(#[from] PolicyIdentityError),
98 #[error("runtime bootstrap declaration snapshot differs from the established binding")]
100 DeclarationSnapshotMismatch,
101 #[error("runtime allocation pool differs from the established host policy")]
103 AllocationPoolMismatch,
104 #[error("runtime bootstrap policy identity changed from {established:?} to {requested:?}")]
106 PolicyIdentityMismatch {
107 established: PolicyIdentity,
109 requested: PolicyIdentity,
111 },
112 #[error(transparent)]
114 LedgerCommit(#[from] crate::LedgerCommitError),
115 #[error(transparent)]
117 StableCellLedger(#[from] StableCellLedgerError),
118 #[error("stable-cell ledger record size {value_size} cannot be written to stable memory")]
120 StableCellLedgerWriteTooLarge {
121 value_size: usize,
123 },
124 #[error(transparent)]
126 LedgerGrowth(#[from] RuntimeGrowError),
127 #[error(transparent)]
129 Validation(#[from] crate::AllocationValidationError<P>),
130 #[error(transparent)]
132 Staging(#[from] crate::AllocationStageError),
133}
134
135#[non_exhaustive]
142#[derive(Clone, Debug, Eq, thiserror::Error, PartialEq)]
143pub enum RuntimeOpenError {
144 #[error("ic-memory runtime has not completed bootstrap validation")]
146 NotBootstrapped,
147 #[error(transparent)]
149 StableKey(#[from] crate::StableKeyError),
150 #[error("stable key '{0}' was not committed by ic-memory runtime bootstrap")]
152 StableKeyNotCommitted(String),
153 #[error("stable key '{stable_key}' is reserved for ic-memory runtime governance")]
155 ReservedStableKey {
156 stable_key: String,
158 },
159}
160
161#[non_exhaustive]
168#[derive(Debug, thiserror::Error)]
169pub enum RuntimeDiagnosticError {
170 #[error(transparent)]
172 Construction(#[from] RuntimeConstructionError),
173 #[error("ic-memory runtime has not completed bootstrap validation")]
175 NotBootstrapped,
176 #[error("runtime memory growth is already in progress")]
178 ReentrantAccess,
179 #[error(transparent)]
181 LedgerCommit(#[from] LedgerCommitError),
182 #[error(transparent)]
184 StableCellLedger(#[from] StableCellLedgerError),
185}
186
187#[non_exhaustive]
194#[derive(Debug, thiserror::Error)]
195pub enum MemoryResolutionError {
196 #[error("unmanaged MemoryManager ID {id} needs an explicit host exclusion")]
198 UnmanagedAllocation { id: u8 },
199 #[error("no eligible free slot for {stable_key} under authority {authority}")]
200 Exhausted {
201 stable_key: crate::StableKey,
202 authority: String,
203 },
204 #[error(transparent)]
205 Pool(#[from] crate::MemoryAllocationPoolError),
206 #[error(transparent)]
207 Declarations(#[from] MemoryDeclarationError),
208}