miden_client/store/
errors.rs1use alloc::string::String;
2
3use miden_objects::{
4 AccountError, AccountIdError, AssetVaultError, Digest, NoteError, TransactionScriptError,
5 account::AccountId,
6 crypto::merkle::MmrError,
7 utils::{DeserializationError, HexParseError},
8};
9use miden_tx::DataStoreError;
10use thiserror::Error;
11
12use super::note_record::NoteRecordError;
13
14#[derive(Debug, Error)]
19#[allow(clippy::large_enum_variant)]
20pub enum StoreError {
21 #[error("asset vault error")]
22 AssetVaultError(#[from] AssetVaultError),
23 #[error("account code data with root {0} not found")]
24 AccountCodeDataNotFound(Digest),
25 #[error("account data wasn't found for account id {0}")]
26 AccountDataNotFound(AccountId),
27 #[error("account error")]
28 AccountError(#[from] AccountError),
29 #[error("account id error")]
30 AccountIdError(#[from] AccountIdError),
31 #[error("account commitment {0} already exists")]
32 AccountCommitmentAlreadyExists(Digest),
33 #[error("account commitment mismatch for account {0}")]
34 AccountCommitmentMismatch(AccountId),
35 #[error("public key {0} not found")]
36 AccountKeyNotFound(String),
37 #[error("account storage data with root {0} not found")]
38 AccountStorageNotFound(Digest),
39 #[error("chain mmr node at index {0} not found")]
40 ChainMmrNodeNotFound(u64),
41 #[error("error deserializing data from the store")]
42 DataDeserializationError(#[from] DeserializationError),
43 #[error("database-related non-query error: {0}")]
44 DatabaseError(String),
45 #[error("error parsing hex")]
46 HexParseError(#[from] HexParseError),
47 #[error("note record error")]
48 NoteRecordError(#[from] NoteRecordError),
49 #[error("error constructing mmr")]
50 MmrError(#[from] MmrError),
51 #[error("inclusion proof creation error")]
52 NoteInclusionProofError(#[from] NoteError),
53 #[error("note tag {0} is already being tracked")]
54 NoteTagAlreadyTracked(u64),
55 #[error("failed to parse data retrieved from the database: {0}")]
56 ParsingError(String),
57 #[error("failed to retrieve data from the database: {0}")]
58 QueryError(String),
59 #[error("error instantiating transaction script")]
60 TransactionScriptError(#[from] TransactionScriptError),
61 #[error("account vault data for root {0} not found")]
62 VaultDataNotFound(Digest),
63}
64
65impl From<StoreError> for DataStoreError {
66 fn from(value: StoreError) -> Self {
67 match value {
68 StoreError::AccountDataNotFound(account_id) => {
69 DataStoreError::AccountNotFound(account_id)
70 },
71 err => DataStoreError::other_with_source("store error", err),
72 }
73 }
74}