error.rs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. use crate::{amount, asset::Asset, status, storage, token, transaction, AccountId, Amount};
  2. use serde::Serialize;
  3. /// The errors that can happen in the Verax crate
  4. #[derive(thiserror::Error, Debug, Serialize)]
  5. pub enum Error {
  6. /// A transaction error
  7. #[error("Transaction: {0}")]
  8. Transaction(#[from] transaction::Error),
  9. /// Transaction not found
  10. #[error("Transaction not found")]
  11. TxNotFound,
  12. /// An internal conversion error
  13. #[error("Conversion overflow: {0}")]
  14. Overflow(String),
  15. /// An internal conversion error
  16. #[error("Conversion overflow: {0}")]
  17. Underflow(String),
  18. /// A storage error
  19. #[error("Storage: {0}")]
  20. Storage(#[from] storage::Error),
  21. /// A status error
  22. #[error("Status update: {0}")]
  23. Status(#[from] status::Error),
  24. /// The asset is not defined
  25. #[error("Asset {0} is not defined")]
  26. AssetIdNotFound(Asset),
  27. /// The asset is not found
  28. #[error("Asset {0} is not defined")]
  29. AssetNotFound(String),
  30. /// The account has not enough balance to perform the operation
  31. #[error("Not enough funds (asset {1}) for account {0}")]
  32. InsufficientBalance(AccountId, Asset),
  33. /// The amount is invalid
  34. #[error("Invalid amount: {0}")]
  35. InvalidAmount(#[from] amount::Error),
  36. /// Invalid token
  37. #[error("Invalid update token: {0}")]
  38. InvalidToken(#[from] token::Error),
  39. /// Valid update token is required
  40. #[error("Valid update token is required")]
  41. ValidUpdateTokenRequired,
  42. /// Account has negative balance
  43. #[error("Account {0} has negative balance. Withdrawal is not allowed.")]
  44. NegativeBalance(AccountId, Vec<Amount>),
  45. }