Skip to main content

calimero_storage/collections/
error.rs

1//! Error types for storage operations.
2
3use serde::Serialize;
4use thiserror::Error;
5
6use crate::address::PathError;
7use crate::interface::StorageError;
8
9/// General error type for storage operations while interacting with complex collections.
10#[derive(Debug, Error)]
11#[non_exhaustive]
12pub enum StoreError {
13    /// Error while interacting with storage.
14    #[error(transparent)]
15    StorageError(#[from] StorageError),
16    /// Error while interacting with a path.
17    #[error(transparent)]
18    PathError(#[from] PathError),
19    /// Arithmetic overflow occurred during size calculation.
20    #[error("arithmetic overflow: {0}")]
21    ArithmeticOverflow(String),
22}
23
24impl Serialize for StoreError {
25    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
26    where
27        S: serde::Serializer,
28    {
29        serializer.collect_str(self)
30    }
31}