All checks were successful
continuous-integration/drone/push Build is passing
* Improve general settings management by admin
35 lines
755 B
Rust
35 lines
755 B
Rust
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))
|
|
}
|