use thiserror::Error;
#[derive(Debug, Error)]
pub enum CandyError {
#[error("Connection error: {0}")]
Connection(String),
#[error("Query error: {0}")]
Query(String),
#[error("Fetch error: {0}")]
Fetch(String),
#[error("Transaction error: {0}")]
Transaction(String),
#[error("URL parse error: {0}")]
UrlParse(String),
#[error("Internal error: {0}")]
Internal(String),
}
#[cfg(feature = "mysql")]
impl From<::mysql::Error> for CandyError {
fn from(e: ::mysql::Error) -> Self {
CandyError::Query(e.to_string())
}
}
#[cfg(feature = "postgres")]
impl From<::postgres::Error> for CandyError {
fn from(e: ::postgres::Error) -> Self {
CandyError::Query(e.to_string())
}
}
#[cfg(feature = "sqlite")]
impl From<::rusqlite::Error> for CandyError {
fn from(e: ::rusqlite::Error) -> Self {
CandyError::Query(e.to_string())
}
}