use core::error::Error;
use std::path::PathBuf;
#[derive(Debug)]
pub enum HtmlError {
MissingSourcePath,
MissingOutputPath,
NotValidUtf8Encoding,
MissingClosingTag { tag: String },
MissingOpeningTag { tag: String },
FileNotFound { path: PathBuf },
Other { message: String },
}
impl Error for HtmlError {}
impl core::fmt::Display for HtmlError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
use HtmlError as E;
match self {
E::MissingSourcePath => write!(f, "Missing source_root_path"),
E::MissingOutputPath => write!(f, "Missing output_root_path"),
E::NotValidUtf8Encoding => write!(f, "Non valid UTF8 encoding"),
E::MissingOpeningTag { tag } => write!(f, "Missing opening tag for </{tag}>"),
E::MissingClosingTag { tag } => write!(f, "Missing closing tag for <{tag}>"),
E::FileNotFound { path } => write!(f, "File not found: {path:?}"),
E::Other { message } => write!(f, "{message}"),
}
}
}
impl TryFrom<std::io::Error> for HtmlError {
type Error = ();
fn try_from(_value: std::io::Error) -> Result<Self, Self::Error> {
Err(())
}
}