miden_crypto/merkle/smt/large/error.rs
1use thiserror::Error;
2
3use super::{MerkleError, StorageError};
4use crate::Word;
5
6// ERROR TYPES
7// ================================================================================================
8
9/// Errors that can occur during LargeSmt operations.
10#[derive(Debug, Error)]
11pub enum LargeSmtError {
12 /// A Merkle tree operation failed.
13 #[error("merkle operation failed")]
14 Merkle(#[from] MerkleError),
15
16 /// A storage operation failed.
17 #[error("storage operation failed")]
18 Storage(#[from] StorageError),
19
20 /// The reconstructed root does not match the expected root.
21 #[error("root mismatch: expected {expected:?}, got {actual:?}")]
22 RootMismatch {
23 /// The expected root hash.
24 expected: Word,
25 /// The actual reconstructed root hash.
26 actual: Word,
27 },
28
29 /// Storage already contains data when trying to create a new tree.
30 ///
31 /// Use [`super::LargeSmt::load_with_root()`] or [`super::LargeSmt::load()`] to load
32 /// existing storage.
33 #[error("storage is not empty")]
34 StorageNotEmpty,
35}
36
37#[cfg(test)]
38// Compile-time assertion that LargeSmtError implements the required traits
39const _: fn() = || {
40 fn assert_impl<T: std::error::Error + Send + Sync + 'static>() {}
41 assert_impl::<LargeSmtError>();
42 assert_impl::<MerkleError>();
43 assert_impl::<StorageError>();
44};