From 8d173950a74f0269bbde20cfe66a97c6b1498956 Mon Sep 17 00:00:00 2001 From: Jim Hodapp Date: Thu, 30 Nov 2023 17:29:47 -0600 Subject: [PATCH] Change EntityApiErrorType to EntityApiError --- entity_api/src/error.rs | 16 ++++++++-------- web/src/error.rs | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/entity_api/src/error.rs b/entity_api/src/error.rs index 32d35b7..fd2d36f 100644 --- a/entity_api/src/error.rs +++ b/entity_api/src/error.rs @@ -12,11 +12,11 @@ pub struct Error { // Underlying error emitted from seaORM internals pub inner: DbErr, // Enum representing which category of error - pub error_type: EntityApiErrorType, + pub error_type: EntityApiError, } #[derive(Debug)] -pub enum EntityApiErrorType { +pub enum EntityApiError { DatabaseConnectionLost, // Record not found RecordNotFound, @@ -39,27 +39,27 @@ impl From for Error { match err { DbErr::RecordNotFound(_) => Error { inner: err, - error_type: EntityApiErrorType::RecordNotFound, + error_type: EntityApiError::RecordNotFound, }, DbErr::RecordNotUpdated => Error { inner: err, - error_type: EntityApiErrorType::RecordNotUpdated, + error_type: EntityApiError::RecordNotUpdated, }, DbErr::ConnectionAcquire(_) => Error { inner: err, - error_type: EntityApiErrorType::SystemError, + error_type: EntityApiError::SystemError, }, DbErr::Conn(_) => Error { inner: err, - error_type: EntityApiErrorType::DatabaseConnectionLost, + error_type: EntityApiError::DatabaseConnectionLost, }, DbErr::Exec(_) => Error { inner: err, - error_type: EntityApiErrorType::SystemError, + error_type: EntityApiError::SystemError, }, _ => Error { inner: err, - error_type: EntityApiErrorType::SystemError, + error_type: EntityApiError::SystemError, }, } } diff --git a/web/src/error.rs b/web/src/error.rs index 8a5f1a7..e16e9c4 100644 --- a/web/src/error.rs +++ b/web/src/error.rs @@ -4,8 +4,8 @@ use axum::http::StatusCode; use axum::response::{IntoResponse, Response}; use serde::Serialize; -use entity_api::error::EntityApiErrorType; -use entity_api::error::Error as EntityApiError; +use entity_api::error::EntityApiError; +use entity_api::error::Error as EntityApiErrorSuper; pub type Result = core::result::Result; @@ -45,13 +45,13 @@ impl IntoResponse for Error { } } -impl From for Error { - fn from(err: EntityApiError) -> Self { +impl From for Error { + fn from(err: EntityApiErrorSuper) -> Self { match err.error_type { - EntityApiErrorType::DatabaseConnectionLost => Error::DatabaseConnectionLost, - EntityApiErrorType::RecordNotFound => Error::EntityNotFound, - EntityApiErrorType::RecordNotUpdated => Error::UnprocessableEntity, - EntityApiErrorType::SystemError => Error::InternalServer, + EntityApiError::DatabaseConnectionLost => Error::DatabaseConnectionLost, + EntityApiError::RecordNotFound => Error::EntityNotFound, + EntityApiError::RecordNotUpdated => Error::UnprocessableEntity, + EntityApiError::SystemError => Error::InternalServer, } } }