1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, PrivacyCashError>;
7
8#[derive(Error, Debug)]
10pub enum PrivacyCashError {
11 #[error("Invalid keypair: {0}")]
13 InvalidKeypair(String),
14
15 #[error("Invalid input: {0}")]
17 InvalidInput(String),
18
19 #[error("Insufficient balance: have {have} lamports, need {need} lamports")]
21 InsufficientBalance { have: u64, need: u64 },
22
23 #[error("Insufficient {token} balance: have {have}, need {need}")]
25 InsufficientTokenBalance {
26 token: String,
27 have: u64,
28 need: u64,
29 },
30
31 #[error("No UTXOs available for withdrawal")]
33 NoUtxosAvailable,
34
35 #[error("Deposit amount {amount} exceeds limit {limit}")]
37 DepositLimitExceeded { amount: u64, limit: u64 },
38
39 #[error("Withdrawal amount too low, minimum is {minimum}")]
41 WithdrawalAmountTooLow { minimum: u64 },
42
43 #[error("Token not supported: {0}")]
45 TokenNotSupported(String),
46
47 #[error("Encryption error: {0}")]
49 EncryptionError(String),
50
51 #[error("Decryption error: {0}")]
53 DecryptionError(String),
54
55 #[error("Proof generation error: {0}")]
57 ProofGenerationError(String),
58
59 #[error("Merkle proof error: {0}")]
61 MerkleProofError(String),
62
63 #[error("API request error: {0}")]
65 ApiError(String),
66
67 #[error("Transaction error: {0}")]
69 TransactionError(String),
70
71 #[error("Transaction confirmation timeout after {retries} retries")]
73 ConfirmationTimeout { retries: u32 },
74
75 #[error("Solana client error: {0}")]
77 SolanaClientError(#[from] solana_client::client_error::ClientError),
78
79 #[error("Serialization error: {0}")]
81 SerializationError(String),
82
83 #[error("IO error: {0}")]
85 IoError(#[from] std::io::Error),
86
87 #[error("HTTP error: {0}")]
89 HttpError(#[from] reqwest::Error),
90
91 #[error("JSON error: {0}")]
93 JsonError(#[from] serde_json::Error),
94
95 #[error("Configuration error: {0}")]
97 ConfigError(String),
98
99 #[error("Storage error: {0}")]
101 StorageError(String),
102
103 #[error("Circuit file not found: {0}")]
105 CircuitNotFound(String),
106
107 #[error("Operation aborted")]
109 Aborted,
110}