1use std::path::PathBuf;
2#[derive(Debug)]
3pub enum Error {
4 Io(std::io::Error),
5 WalkDir(walkdir::Error),
6 Yaml(serde_yaml::Error),
7 DescriptionInvalid(PathBuf),
8}
9
10impl std::fmt::Display for Error {
11 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
12 match self {
13 Error::Io(e) => e.fmt(f),
14 Error::WalkDir(e) => e.fmt(f),
15 Error::Yaml(e) => e.fmt(f),
16 Error::DescriptionInvalid(path) => {
17 write!(f, "Unable to extract description for {:?}", path)
18 }
19 }
20 }
21}
22impl std::error::Error for Error {}
23
24impl From<std::io::Error> for Error {
25 fn from(other: std::io::Error) -> Self {
26 Self::Io(other)
27 }
28}
29
30impl From<walkdir::Error> for Error {
31 fn from(other: walkdir::Error) -> Self {
32 Self::WalkDir(other)
33 }
34}
35
36impl From<serde_yaml::Error> for Error {
37 fn from(other: serde_yaml::Error) -> Self {
38 Self::Yaml(other)
39 }
40}