use sea_orm::DbErr; #[derive(Debug)] pub enum ServiceError { NotFound(String), DatabaseError(String), Unauthorized(String), InternalError(String), BadRequest(String), } impl From> for ServiceError { fn from(err: Box) -> Self { ServiceError::InternalError(err.to_string()) } } impl From for ServiceError { fn from(err: DbErr) -> Self { match err { DbErr::RecordNotFound(msg) => ServiceError::NotFound(msg), _ => ServiceError::DatabaseError(err.to_string()), } } }