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