1use std::path::PathBuf;
5
6pub type Result<T> = std::result::Result<T, Error>;
7
8#[derive(Debug)]
10pub enum Error {
11 Io(std::io::Error),
13 NotFound(PathBuf),
15 Parse { path: PathBuf, message: String },
17 Table {
20 path: PathBuf,
21 row: usize,
22 message: String,
23 },
24 Deserialize(String),
26 Unsupported(String),
28}
29
30impl std::fmt::Display for Error {
31 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32 match self {
33 Error::Io(e) => write!(f, "io error: {e}"),
34 Error::NotFound(p) => write!(f, "source not found: {}", p.display()),
35 Error::Parse { path, message } => write!(f, "{}: {message}", path.display()),
36 Error::Table { path, row, message } => {
37 write!(f, "{} row {row}: {message}", path.display())
38 }
39 Error::Deserialize(m) => write!(f, "deserialize error: {m}"),
40 Error::Unsupported(m) => write!(f, "unsupported: {m}"),
41 }
42 }
43}
44
45impl std::error::Error for Error {}