use std::path::{Path, PathBuf};
#[derive(Debug)]
pub struct Error {
io_error: std::io::Error,
path: PathBuf,
}
impl Error {
pub fn new(io_error: std::io::Error, path: PathBuf) -> Self {
Error { io_error, path }
}
pub fn io_error(&self) -> &std::io::Error {
&self.io_error
}
pub fn path(&self) -> &Path {
&self.path
}
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}: {}", self.path.display(), self.io_error)
}
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
Some(&self.io_error)
}
}