ethereum-mysql 4.0.0

Ethereum types (Address, U256) wrapper for seamless SQL database integration with SQLx
Documentation
//! Unified error type for ethereum-mysql type conversions.
//!
//! `SqlTypeError` provides a single error type for all conversion failures
//! across the crate, replacing ad-hoc `&'static str` errors.

use std::fmt;

/// Errors that can occur when converting between Rust primitives and Ethereum SQL types.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SqlTypeError {
    /// Attempted to convert a negative value to an unsigned integer type.
    NegativeValue,
    /// Value is too large for the target type.
    Overflow,
    /// The input string could not be parsed into the target Ethereum type.
    /// Wraps the underlying parse error from alloy / ruint.
    InvalidFormat(String),
}

impl fmt::Display for SqlTypeError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            SqlTypeError::NegativeValue => {
                write!(f, "cannot convert negative value to unsigned integer")
            }
            SqlTypeError::Overflow => {
                write!(f, "value overflow — exceeds target type range")
            }
            SqlTypeError::InvalidFormat(msg) => {
                write!(f, "invalid format: {msg}")
            }
        }
    }
}

impl std::error::Error for SqlTypeError {}