use super::*;
impl DbError {
pub fn new(error: sea_orm::DbErr) -> Self {
Self::Connection(error)
}
pub fn message(&self) -> String {
match self {
DbError::Connection(e) => e.to_string(),
DbError::Config(msg) => msg.clone(),
DbError::Permission(msg) => msg.clone(),
DbError::Transaction(msg) => msg.clone(),
DbError::Migration(msg) => msg.clone(),
#[cfg(feature = "validation")]
DbError::Validation(msg) => msg.clone(),
}
}
}
impl From<String> for DbError {
fn from(msg: String) -> Self {
Self::Config(msg)
}
}
impl From<&str> for DbError {
fn from(msg: &str) -> Self {
Self::Config(msg.to_string())
}
}