use tork_core::{Error, ErrorKind as HttpKind};
use crate::error::{ErrorKind, OrmError};
impl From<OrmError> for Error {
fn from(error: OrmError) -> Self {
let kind = match error.kind() {
ErrorKind::Connection => HttpKind::ServiceUnavailable,
ErrorKind::NotFound => HttpKind::NotFound,
ErrorKind::Conflict => HttpKind::Conflict,
ErrorKind::MultipleFound
| ErrorKind::Query
| ErrorKind::Conversion
| ErrorKind::Configuration => HttpKind::Internal,
};
let message = error.to_string();
Error::new(kind, message).with_source(error)
}
}