From abbdec49e7e3b42e323dadb8dc10aa8ef2c1e462 Mon Sep 17 00:00:00 2001 From: Awiteb Date: Fri, 12 Jul 2024 23:23:16 +0300 Subject: [PATCH] change: Rename `DuplicatedUser` error to `AlreadyRegistered` Signed-off-by: Awiteb --- crates/oxidetalis/src/database/user.rs | 2 +- crates/oxidetalis/src/errors.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/oxidetalis/src/database/user.rs b/crates/oxidetalis/src/database/user.rs index 3230aa3..4cc27a0 100644 --- a/crates/oxidetalis/src/database/user.rs +++ b/crates/oxidetalis/src/database/user.rs @@ -53,7 +53,7 @@ impl UserTableExt for DatabaseConnection { .await { if let Some(SqlErr::UniqueConstraintViolation(_)) = err.sql_err() { - return Err(ApiError::DuplicatedUser); + return Err(ApiError::AlreadyRegistered); } } diff --git a/crates/oxidetalis/src/errors.rs b/crates/oxidetalis/src/errors.rs index 95f6b2f..325cfc3 100644 --- a/crates/oxidetalis/src/errors.rs +++ b/crates/oxidetalis/src/errors.rs @@ -48,7 +48,7 @@ pub enum ApiError { RegistrationClosed, /// The entered public key is already registered (400 Bad Request) #[error("The entered public key is already registered")] - DuplicatedUser, + AlreadyRegistered, /// The user entered two different public keys /// one in the header and other in the request body /// (400 Bad Request) @@ -62,7 +62,7 @@ impl ApiError { match self { Self::SeaOrm(_) => StatusCode::INTERNAL_SERVER_ERROR, Self::RegistrationClosed => StatusCode::FORBIDDEN, - Self::DuplicatedUser | Self::TwoDifferentKeys => StatusCode::BAD_REQUEST, + Self::AlreadyRegistered | Self::TwoDifferentKeys => StatusCode::BAD_REQUEST, } } }