1use std::fmt::{self, Display, Formatter};
2
3#[derive(Debug)]
4pub enum Error {
5 RequestError(reqwest::Error),
6 ParseError(serde_json::Error),
7 NoMorePages,
8 CacheMiss,
9}
10
11impl From<reqwest::Error> for Error {
12 fn from(error: reqwest::Error) -> Self {
13 Error::RequestError(error)
14 }
15}
16
17impl From<serde_json::Error> for Error {
18 fn from(error: serde_json::Error) -> Self {
19 Error::ParseError(error)
20 }
21}
22
23impl Display for Error {
24 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
25 match self {
26 Error::RequestError(error) => write!(f, "RequestError: {}", error),
27 Error::ParseError(error) => write!(f, "ParseError: {}", error),
28 Error::NoMorePages => write!(f, "NoMorePages"),
29 Error::CacheMiss => write!(f, "CacheMiss"),
30 }
31 }
32}
33
34impl std::error::Error for Error {}