1#[derive(thiserror::Error, Debug)]
2pub enum Error {
3 #[error("{0}")]
4 Generic(String),
5 #[error("connection error: {0}")]
6 ConnectionError(String),
7 #[error("io error: {0}")]
8 IO(#[from] std::io::Error),
9 #[error("serialisation error: {0}")]
10 Serialisation(String),
11 #[error("deserialisation error: {0}")]
12 Deserialisation(String),
13 #[error("no such font family: {0}")]
14 NoSuchFamily(String),
15}
16pub type Result<T> = std::result::Result<T, Error>;
17
18#[cfg(feature = "reqwest-util")]
19impl From<reqwest::Error> for Error {
20 fn from(err: reqwest::Error) -> Self {
21 if err.is_connect() {
23 Error::ConnectionError(format!("{}", err))
24 } else {
25 Error::Generic(format!("{}", err))
26 }
27 }
28}