Skip to main content

tenzro_wallet/
error.rs

1//! Error types for Tenzro Network wallet operations.
2
3use thiserror::Error;
4
5/// Wallet-specific errors for Tenzro Network.
6#[derive(Debug, Error)]
7pub enum WalletError {
8    /// Wallet not found
9    #[error("Wallet not found: {0}")]
10    WalletNotFound(String),
11
12    /// Invalid wallet ID
13    #[error("Invalid wallet ID: {0}")]
14    InvalidWalletId(String),
15
16    /// Wallet already exists
17    #[error("Wallet already exists: {0}")]
18    WalletAlreadyExists(String),
19
20    /// Insufficient balance
21    #[error("Insufficient balance: have {have}, need {need}")]
22    InsufficientBalance { have: u128, need: u128 },
23
24    /// Asset not supported
25    #[error("Asset not supported: {0}")]
26    AssetNotSupported(String),
27
28    /// Invalid key share
29    #[error("Invalid key share: {0}")]
30    InvalidKeyShare(String),
31
32    /// Threshold not met
33    #[error("Threshold not met: got {got}, need {need}")]
34    ThresholdNotMet { got: usize, need: usize },
35
36    /// Signature generation failed
37    #[error("Signature generation failed: {0}")]
38    SignatureFailed(String),
39
40    /// Keystore error
41    #[error("Keystore error: {0}")]
42    KeystoreError(String),
43
44    /// Encryption error
45    #[error("Encryption error: {0}")]
46    EncryptionError(String),
47
48    /// Decryption error
49    #[error("Decryption error: {0}")]
50    DecryptionError(String),
51
52    /// Invalid password
53    #[error("Invalid password")]
54    InvalidPassword,
55
56    /// Provisioning failed
57    #[error("Provisioning failed: {0}")]
58    ProvisioningFailed(String),
59
60    /// Transaction validation failed
61    #[error("Transaction validation failed: {0}")]
62    TransactionValidationFailed(String),
63
64    /// Signature verification failed
65    #[error("Signature verification failed: {0}")]
66    SignatureVerificationFailed(String),
67
68    /// Contact not found
69    #[error("Contact not found: {0}")]
70    ContactNotFound(String),
71
72    /// State sync error
73    #[error("State sync error: {0}")]
74    StateSyncError(String),
75
76    /// Serialization error
77    #[error("Serialization error: {0}")]
78    SerializationError(String),
79
80    /// Cryptographic error
81    #[error("Crypto error: {0}")]
82    CryptoError(#[from] tenzro_crypto::CryptoError),
83
84    /// IO error
85    #[error("IO error: {0}")]
86    IoError(#[from] std::io::Error),
87
88    /// Generic error
89    #[error("{0}")]
90    Other(String),
91}
92
93/// Result type for wallet operations in Tenzro Network.
94pub type Result<T> = std::result::Result<T, WalletError>;