miden_client/store/
errors.rs1use alloc::string::String;
2
3use miden_objects::{
4 account::AccountId,
5 crypto::merkle::MmrError,
6 utils::{DeserializationError, HexParseError},
7 AccountError, AccountIdError, AssetVaultError, Digest, NoteError, TransactionScriptError,
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 hash {0} already exists")]
32 AccountHashAlreadyExists(Digest),
33 #[error("account hash mismatch for account {0}")]
34 AccountHashMismatch(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: {0}")]
46 HexParseError(HexParseError),
48 #[error("note record error")]
49 NoteRecordError(#[from] NoteRecordError),
50 #[error("error constructing mmr: {0}")]
51 MmrError(MmrError),
53 #[error("inclusion proof creation error")]
54 NoteInclusionProofError(#[from] NoteError),
55 #[error("note tag {0} is already being tracked")]
56 NoteTagAlreadyTracked(u64),
57 #[error("failed to parse data retrieved from the database: {0}")]
58 ParsingError(String),
59 #[error("failed to retrieve data from the database: {0}")]
60 QueryError(String),
61 #[error("error instantiating transaction script")]
62 TransactionScriptError(#[from] TransactionScriptError),
63 #[error("account vault data for root {0} not found")]
64 VaultDataNotFound(Digest),
65}
66
67impl From<HexParseError> for StoreError {
68 fn from(value: HexParseError) -> Self {
69 StoreError::HexParseError(value)
70 }
71}
72
73impl From<MmrError> for StoreError {
74 fn from(value: MmrError) -> Self {
75 StoreError::MmrError(value)
76 }
77}
78
79impl From<StoreError> for DataStoreError {
80 fn from(value: StoreError) -> Self {
81 match value {
82 StoreError::AccountDataNotFound(account_id) => {
83 DataStoreError::AccountNotFound(account_id)
84 },
85 err => DataStoreError::other_with_source("store error", err),
86 }
87 }
88}