1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
use tera::{Error, ErrorKind};
use crate::{XError, XErrorKind};
impl From<Error> for XError {
fn from(error: Error) -> Self {
let mut out = XError::default();
match error.kind {
ErrorKind::Io(e) => {
let error = std::io::Error::from(e);
out.kind = Box::new(XErrorKind::from(&error));
}
_ => {
out.kind = Box::new(XErrorKind::SyntaxError { message: error.to_string() });
out.source = Some(Box::new(error))
}
}
out
}
}