use crate::{amount, asset::Asset, status, storage, token, transaction, AccountId, Amount}; use serde::Serialize; /// The errors that can happen in the Verax crate #[derive(thiserror::Error, Debug, Serialize)] pub enum Error { /// A transaction error #[error("Transaction: {0}")] Transaction(#[from] transaction::Error), /// Transaction not found #[error("Transaction not found")] TxNotFound, /// An internal conversion error #[error("Conversion overflow: {0}")] Overflow(String), /// An internal conversion error #[error("Conversion overflow: {0}")] Underflow(String), /// A storage error #[error("Storage: {0}")] Storage(#[from] storage::Error), /// A status error #[error("Status update: {0}")] Status(#[from] status::Error), /// The asset is not defined #[error("Asset {0} is not defined")] AssetIdNotFound(Asset), /// The asset is not found #[error("Asset {0} is not defined")] AssetNotFound(String), /// The account has not enough balance to perform the operation #[error("Not enough funds (asset {1}) for account {0}")] InsufficientBalance(AccountId, Asset), /// The amount is invalid #[error("Invalid amount: {0}")] InvalidAmount(#[from] amount::Error), /// Invalid token #[error("Invalid update token: {0}")] InvalidToken(#[from] token::Error), /// Valid update token is required #[error("Valid update token is required")] ValidUpdateTokenRequired, /// Account has negative balance #[error("Account {0} has negative balance. Withdrawal is not allowed.")] NegativeBalance(AccountId, Vec), }