1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use std::fmt::Debug;
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),
}
}
}