From 0895f0892eb8a328d98889a797538534e68dd90a Mon Sep 17 00:00:00 2001 From: Samuel Lorch Date: Wed, 1 Nov 2023 15:11:28 +0100 Subject: [PATCH] Use Correct Error --- src/api/mod.rs | 3 +++ src/api/system.rs | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/api/mod.rs b/src/api/mod.rs index a8d8bee..9d42434 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -19,6 +19,9 @@ pub enum ApiError { #[error("Not Found")] NotFound, + #[error("Already Exists")] + AlreadyExists, + #[error("Hash Error")] HashError(#[from] pwhash::error::Error), diff --git a/src/api/system.rs b/src/api/system.rs index 4461a14..2f49699 100644 --- a/src/api/system.rs +++ b/src/api/system.rs @@ -7,6 +7,7 @@ use jsonrpsee::RpcModule; use pwhash::sha512_crypt; use serde::{Deserialize, Serialize}; +use ApiError::AlreadyExists; use ApiError::ConfigError; use ApiError::HashError; use ApiError::NotFound; @@ -124,7 +125,7 @@ pub fn create_user(p: Params, state: &RpcState) -> Result<(), ApiError> { .map_err(ConfigError) } else { tx.revert(); - Err(NotFound) + Err(AlreadyExists) } }