//! Error types for the desktop wallet use serde::{Serialize, Serializer}; /// Result type for wallet operations pub type Result = std::result::Result; /// Wallet error types #[derive(Debug, thiserror::Error)] pub enum Error { #[error("Wallet is locked")] WalletLocked, #[error("Wallet not found")] WalletNotFound, #[error("Invalid password")] InvalidPassword, #[error("Invalid mnemonic phrase")] InvalidMnemonic, #[error("Insufficient balance: have {available}, need {required}")] InsufficientBalance { available: u64, required: u64 }, #[error("Transaction error: {0}")] Transaction(String), #[error("Network error: {0}")] Network(String), #[error("RPC error: {0}")] Rpc(String), #[error("Crypto error: {0}")] Crypto(String), #[error("IO error: {0}")] Io(#[from] std::io::Error), #[error("Serialization error: {0}")] Serialization(String), #[error("Keychain error: {0}")] Keychain(String), #[error("Internal error: {0}")] Internal(String), } impl Serialize for Error { fn serialize(&self, serializer: S) -> std::result::Result where S: Serializer, { serializer.serialize_str(&self.to_string()) } }