/ abzu-token / src / error.rs
error.rs
 1  //! Token error types
 2  
 3  use thiserror::Error;
 4  
 5  /// Errors that can occur during token operations
 6  #[derive(Error, Debug, Clone, PartialEq, Eq)]
 7  pub enum TokenError {
 8      /// Insufficient balance for operation
 9      #[error("insufficient balance: have {have}, need {need}")]
10      InsufficientBalance { have: u128, need: u128 },
11  
12      /// Arithmetic overflow
13      #[error("balance overflow")]
14      Overflow,
15  
16      /// Arithmetic underflow
17      #[error("balance underflow")]
18      Underflow,
19  
20      /// Bond is locked and cannot be modified
21      #[error("bond is locked until {unlock_time}")]
22      BondLocked { unlock_time: String },
23  
24      /// Bond is in cooldown period
25      #[error("bond is in cooldown, {remaining} remaining")]
26      BondInCooldown { remaining: String },
27  
28      /// Bond has been slashed
29      #[error("bond has been slashed")]
30      BondSlashed,
31  
32      /// Address not found in ledger
33      #[error("address not found: {0}")]
34      AddressNotFound(String),
35  
36      /// Invalid address format
37      #[error("invalid address format")]
38      InvalidAddress,
39  
40      /// Bonding curve has sunset (Year 1 ended)
41      #[error("bonding curve has sunset, use peer-to-peer market")]
42      CurveSunset,
43  
44      /// Insufficient supply remaining
45      #[error("insufficient supply remaining")]
46      InsufficientSupply,
47  
48      /// Insufficient reserve for operation
49      #[error("insufficient reserve")]
50      InsufficientReserve,
51  
52      /// Insufficient funds for purchase
53      #[error("insufficient funds")]
54      InsufficientFunds,
55  
56      /// Lock was poisoned
57      #[error("internal lock poisoned")]
58      LockPoisoned,
59  
60      /// Storage backend error
61      #[error("storage error: {0}")]
62      Storage(String),
63  }