1use std::error::Error;
2use std::fmt::{Debug, Display};
3
4pub type Result<T> = std::result::Result<T, XMLError>;
6
7pub enum XMLError {
9 InsertError(String),
11 IOError(String),
13}
14
15impl From<std::io::Error> for XMLError {
16 fn from(e: std::io::Error) -> Self {
17 XMLError::IOError(e.to_string())
18 }
19}
20
21impl Debug for XMLError {
22 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23 match self {
24 XMLError::InsertError(e) => write!(f, "Error encountered during insertion: {}", e),
25 XMLError::IOError(e) => write!(f, "Error encountered during write: {}", e),
26 }
27 }
28}
29
30impl Display for XMLError {
31 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32 write!(f, "{self:?}")
33 }
34}
35
36impl Error for XMLError {}