error.rs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. /// An internal conversion error
  10. #[error("Conversion overflow: {0}")]
  11. Overflow(String),
  12. /// An internal conversion error
  13. #[error("Conversion overflow: {0}")]
  14. Underflow(String),
  15. /// A storage error
  16. #[error("Storage: {0}")]
  17. Storage(#[from] storage::Error),
  18. /// The asset is not defined
  19. #[error("Asset {0} is not defined")]
  20. AssetIdNotFound(Asset),
  21. /// The asset is not found
  22. #[error("Asset {0} is not defined")]
  23. AssetNotFound(String),
  24. /// The account has not enough balance to perform the operation
  25. #[error("Not enough funds (asset {1}) for account {0}")]
  26. InsufficientBalance(AccountId, Asset),
  27. /// The amount is invalid
  28. #[error("Invalid amount: {0}")]
  29. InvalidAmount(#[from] amount::Error),
  30. }