ic_storage/adapter/
error.rs1#[derive(Clone, Copy, Debug, Eq, PartialEq, thiserror::Error)]
9pub enum CollectionError {
10 #[error("{0}")]
12 Codec(#[from] crate::storable::CodecError),
13 #[error("invalid collection: {0}")]
15 Corrupt(&'static str),
16 #[error("unrecognized collection format")]
18 Format,
19 #[error("collection checksum mismatch")]
21 Checksum,
22 #[error("collection resource budget exceeded")]
24 Budget,
25 #[error("collection growth refused")]
27 Growth,
28 #[error("collection memory is not empty")]
30 NotEmpty,
31 #[error("collection owner is poisoned")]
33 Poisoned,
34 #[error("invalid collection index or range")]
36 Bounds,
37 #[error("collection Wire record: {0}")]
39 Wire(#[from] ic_wire::Error),
40 #[error("{0}")]
42 Cell(#[from] crate::StableCellPayloadError),
43}
44
45pub(super) type Result<T> = std::result::Result<T, CollectionError>;
46
47pub(super) fn ensure(condition: bool, error: CollectionError) -> Result<()> {
48 if condition { Ok(()) } else { Err(error) }
49}