Refactor users management (#7)
All checks were successful
continuous-integration/drone/push Build is passing

* Improve general settings management by admin
This commit is contained in:
2022-11-26 16:06:16 +01:00
parent a2d731bfff
commit fc6ab00e30
6 changed files with 166 additions and 58 deletions

View File

@ -1,2 +1,34 @@
use std::error::Error;
use std::fmt;
use std::fmt::{Display, Formatter};
pub type Res<A = ()> = Result<A, Box<dyn Error>>;
#[derive(Debug, Clone)]
pub struct ExecError(pub String);
impl ExecError {
pub fn new(msg: &str) -> ExecError {
ExecError(msg.to_string())
}
pub fn boxed_new<D: Display>(msg: D) -> Box<ExecError> {
Box::new(ExecError(msg.to_string()))
}
pub fn boxed_string(msg: String) -> Box<ExecError> {
Box::new(ExecError(msg))
}
}
impl Display for ExecError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "Encountered error: {}", self.0)
}
}
impl Error for ExecError {}
pub fn new_error<D: Display>(msg: D) -> Res {
Err(ExecError::boxed_new(msg))
}