use std::error::Error;
use std::fmt::{Debug, Display};
pub type Result<T> = std::result::Result<T, XMLError>;
pub enum XMLError {
InsertError(String),
IOError(String),
}
impl From<std::io::Error> for XMLError {
fn from(e: std::io::Error) -> Self {
XMLError::IOError(e.to_string())
}
}
impl Debug for XMLError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
XMLError::InsertError(e) => write!(f, "Error encountered during insertion: {}", e),
XMLError::IOError(e) => write!(f, "Error encountered during write: {}", e),
}
}
}
impl Display for XMLError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{self:?}")
}
}
impl Error for XMLError {}