mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-10 18:38:22 +00:00
Use Correct Error
This commit is contained in:
parent
277753dde5
commit
0895f0892e
2 changed files with 5 additions and 1 deletions
|
@ -19,6 +19,9 @@ pub enum ApiError {
|
||||||
#[error("Not Found")]
|
#[error("Not Found")]
|
||||||
NotFound,
|
NotFound,
|
||||||
|
|
||||||
|
#[error("Already Exists")]
|
||||||
|
AlreadyExists,
|
||||||
|
|
||||||
#[error("Hash Error")]
|
#[error("Hash Error")]
|
||||||
HashError(#[from] pwhash::error::Error),
|
HashError(#[from] pwhash::error::Error),
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ use jsonrpsee::RpcModule;
|
||||||
use pwhash::sha512_crypt;
|
use pwhash::sha512_crypt;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use ApiError::AlreadyExists;
|
||||||
use ApiError::ConfigError;
|
use ApiError::ConfigError;
|
||||||
use ApiError::HashError;
|
use ApiError::HashError;
|
||||||
use ApiError::NotFound;
|
use ApiError::NotFound;
|
||||||
|
@ -124,7 +125,7 @@ pub fn create_user(p: Params, state: &RpcState) -> Result<(), ApiError> {
|
||||||
.map_err(ConfigError)
|
.map_err(ConfigError)
|
||||||
} else {
|
} else {
|
||||||
tx.revert();
|
tx.revert();
|
||||||
Err(NotFound)
|
Err(AlreadyExists)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue