From 1c30767592b2f204c70189f0a80580f7cbee8016 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 2 Dec 2022 19:20:51 +0100 Subject: [PATCH] Remove stale `Error` variant Co-Authored-By: Max Brunsfeld --- crates/collab/src/db.rs | 2 +- crates/collab/src/lib.rs | 16 ++-------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/crates/collab/src/db.rs b/crates/collab/src/db.rs index 2a8163b9c8..fd1ed7d50f 100644 --- a/crates/collab/src/db.rs +++ b/crates/collab/src/db.rs @@ -2203,7 +2203,7 @@ impl Database { match f(tx).await { Ok(result) => return Ok(result), Err(error) => match error { - Error::Database2( + Error::Database( DbErr::Exec(sea_orm::RuntimeErr::SqlxError(error)) | DbErr::Query(sea_orm::RuntimeErr::SqlxError(error)), ) if error diff --git a/crates/collab/src/lib.rs b/crates/collab/src/lib.rs index 9011d2a1eb..24a9fc6117 100644 --- a/crates/collab/src/lib.rs +++ b/crates/collab/src/lib.rs @@ -15,8 +15,7 @@ pub type Result = std::result::Result; pub enum Error { Http(StatusCode, String), - Database(sqlx::Error), - Database2(sea_orm::error::DbErr), + Database(sea_orm::error::DbErr), Internal(anyhow::Error), } @@ -26,15 +25,9 @@ impl From for Error { } } -impl From for Error { - fn from(error: sqlx::Error) -> Self { - Self::Database(error) - } -} - impl From for Error { fn from(error: sea_orm::error::DbErr) -> Self { - Self::Database2(error) + Self::Database(error) } } @@ -63,9 +56,6 @@ impl IntoResponse for Error { Error::Database(error) => { (StatusCode::INTERNAL_SERVER_ERROR, format!("{}", &error)).into_response() } - Error::Database2(error) => { - (StatusCode::INTERNAL_SERVER_ERROR, format!("{}", &error)).into_response() - } Error::Internal(error) => { (StatusCode::INTERNAL_SERVER_ERROR, format!("{}", &error)).into_response() } @@ -78,7 +68,6 @@ impl std::fmt::Debug for Error { match self { Error::Http(code, message) => (code, message).fmt(f), Error::Database(error) => error.fmt(f), - Error::Database2(error) => error.fmt(f), Error::Internal(error) => error.fmt(f), } } @@ -89,7 +78,6 @@ impl std::fmt::Display for Error { match self { Error::Http(code, message) => write!(f, "{code}: {message}"), Error::Database(error) => error.fmt(f), - Error::Database2(error) => error.fmt(f), Error::Internal(error) => error.fmt(f), } }