altius-tx-sdk 0.2.5

SDK for signing and sending Altius USD multi-token transactions
Documentation
//! Error types for the SDK

use thiserror::Error;

pub type Result<T> = std::result::Result<T, Error>;

#[derive(Debug, Error)]
pub enum Error {
    #[error("Invalid private key: {0}")]
    InvalidPrivateKey(String),

    #[error("Invalid address: {0}")]
    InvalidAddress(String),

    #[error("Invalid hex string: {0}")]
    InvalidHex(String),

    #[error("Signing failed: {0}")]
    SigningFailed(String),

    #[error("Encoding failed: {0}")]
    EncodingFailed(String),

    #[error("Missing required field: {0}")]
    MissingField(String),

    #[error("RLP encoding error: {0}")]
    RlpError(String),

    #[error("RPC error: {0}")]
    Rpc(String),

    #[error("Other error: {0}")]
    Other(String),
}

impl From<hex::FromHexError> for Error {
    fn from(e: hex::FromHexError) -> Self {
        Error::InvalidHex(e.to_string())
    }
}

impl From<alloy_primitives::AddressError> for Error {
    fn from(e: alloy_primitives::AddressError) -> Self {
        Error::InvalidAddress(e.to_string())
    }
}

impl From<reqwest::Error> for Error {
    fn from(e: reqwest::Error) -> Self {
        Error::Other(e.to_string())
    }
}

impl From<std::num::ParseIntError> for Error {
    fn from(e: std::num::ParseIntError) -> Self {
        Error::InvalidHex(e.to_string())
    }
}