org-static/src/error.rs

39 lines
793 B
Rust

pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug)]
pub struct Error {
message: String,
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", &self.message)
}
}
impl std::error::Error for Error {}
impl Error {
pub fn new(message: &str) -> Self {
Error {
message: message.to_string(),
}
}
}
impl From<handlebars::TemplateError> for Error {
fn from(source: handlebars::TemplateError) -> Self {
Self {
message: source.to_string(),
}
}
}
impl From<handlebars::RenderError> for Error {
fn from(source: handlebars::RenderError) -> Self {
Self {
message: source.to_string(),
}
}
}