use std::path::PathBuf;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug)]
pub enum Error {
Io(std::io::Error),
NotFound(PathBuf),
Parse { path: PathBuf, message: String },
Table {
path: PathBuf,
row: usize,
message: String,
},
Deserialize(String),
Unsupported(String),
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Error::Io(e) => write!(f, "io error: {e}"),
Error::NotFound(p) => write!(f, "source not found: {}", p.display()),
Error::Parse { path, message } => write!(f, "{}: {message}", path.display()),
Error::Table { path, row, message } => {
write!(f, "{} row {row}: {message}", path.display())
}
Error::Deserialize(m) => write!(f, "deserialize error: {m}"),
Error::Unsupported(m) => write!(f, "unsupported: {m}"),
}
}
}
impl std::error::Error for Error {}