#[derive(Debug, Clone, thiserror::Error)]
#[non_exhaustive]
pub enum WalletError {
#[error("Derivation error: {0}")]
Derivation(String),
#[error("Signing error: {0}")]
Signing(String),
#[error("Provider error: {0}")]
Provider(String),
#[error("Config error: {0}")]
Config(String),
#[error("Transaction error: {0}")]
Transaction(String),
#[cfg(feature = "x402")]
#[error("x402 payment error: {0}")]
Payment(String),
}
impl WalletError {
#[must_use]
pub fn derivation(msg: impl Into<String>) -> Self {
Self::Derivation(msg.into())
}
#[must_use]
pub fn signing(msg: impl Into<String>) -> Self {
Self::Signing(msg.into())
}
#[must_use]
pub fn provider(msg: impl Into<String>) -> Self {
Self::Provider(msg.into())
}
#[must_use]
pub fn config(msg: impl Into<String>) -> Self {
Self::Config(msg.into())
}
#[must_use]
pub fn transaction(msg: impl Into<String>) -> Self {
Self::Transaction(msg.into())
}
#[cfg(feature = "x402")]
#[must_use]
pub fn payment(msg: impl Into<String>) -> Self {
Self::Payment(msg.into())
}
}
impl From<WalletError> for crate::tool::ToolError {
fn from(e: WalletError) -> Self {
Self::Execution(e.to_string())
}
}