Refactor users management (#7)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
* Improve general settings management by admin
This commit is contained in:
@ -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))
|
||||
}
|
||||
|
Reference in New Issue
Block a user