dameng_rust_sdk 0.1.3

A Rust SDK for Dameng Database (DM8) with ODBC support
Documentation
//! Error handling for Dameng Rust SDK

use std::io;

use odbc_api::{Error as OdbcError};
use chrono::ParseError;
use thiserror::Error;

/// Result type for Dameng SDK operations
pub type Result<T, E = Error> = std::result::Result<T, E>;

/// Error type for Dameng SDK operations
#[derive(Error, Debug)]
pub enum Error {
    /// ODBC related errors
    #[error("ODBC error: {0}")]
    Odbc(#[from] OdbcError),
    
    /// Connection errors
    #[error("Connection error: {0}")]
    Connection(String),
    
    /// Query execution errors
    #[error("Query error: {0}")]
    Query(String),
    
    /// Data type conversion errors
    #[error("Type conversion error: {0}")]
    TypeConversion(String),
    
    /// Encoding/decoding errors
    #[error("Encoding error: {0}")]
    Encoding(String),
    
    /// IO errors
    #[error("IO error: {0}")]
    Io(#[from] io::Error),
    
    /// Parse errors
    #[error("Parse error: {0}")]
    Parse(#[from] ParseError),
    
    /// Serialization/deserialization errors
    #[error("Serialization error: {0}")]
    Serialization(String),
    
    /// Transaction errors
    #[error("Transaction error: {0}")]
    Transaction(String),
    
    /// Configuration errors
    #[error("Configuration error: {0}")]
    Configuration(String),
    
    /// Database errors
    #[error("Database error: {0}")]
    Database(String),
}

impl Error {
    /// Create a new connection error
    pub fn connection(message: impl Into<String>) -> Self {
        Error::Connection(message.into())
    }
    
    /// Create a new query error
    pub fn query(message: impl Into<String>) -> Self {
        Error::Query(message.into())
    }
    
    /// Create a new type conversion error
    pub fn type_conversion(message: impl Into<String>) -> Self {
        Error::TypeConversion(message.into())
    }
    
    /// Create a new serialization error
    pub fn serialization(message: impl Into<String>) -> Self {
        Error::Serialization(message.into())
    }
    
    /// Create a new transaction error
    pub fn transaction(message: impl Into<String>) -> Self {
        Error::Transaction(message.into())
    }
    
    /// Create a new configuration error
    pub fn configuration(message: impl Into<String>) -> Self {
        Error::Configuration(message.into())
    }
    
    /// Create a new database error
    pub fn database(message: impl Into<String>) -> Self {
        Error::Database(message.into())
    }
}