home ~ projects ~ socials

Return A Minijinja Error In A Result

This is just a scratch note to show the basic syntax. I'll make the example better when I get a chance

pub fn url_path(&self) -> Result<Value, Error> {
    if let Some(original_path) = self.html_output_path.clone() {
        let base_path = original_path
            .to_string_lossy()
            .trim_end_matches("index.html")
            .to_string();
        Ok(Value::from(format!("/{}", base_path)))
    } else {
        Err(Error::new(
            ErrorKind::InvalidOperation,
            format!("could not get url_path: "),
        ))
    }
}
-- end of line --