error.rs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. use crate::{amount, asset::Asset, storage, transaction, AccountId};
  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. /// The asset is not defined
  22. #[error("Asset {0} is not defined")]
  23. AssetIdNotFound(Asset),
  24. /// The asset is not found
  25. #[error("Asset {0} is not defined")]
  26. AssetNotFound(String),
  27. /// The account has not enough balance to perform the operation
  28. #[error("Not enough funds (asset {1}) for account {0}")]
  29. InsufficientBalance(AccountId, Asset),
  30. /// The amount is invalid
  31. #[error("Invalid amount: {0}")]
  32. InvalidAmount(#[from] amount::Error),
  33. }