pixiv_api/errors/
convert.rs

1use tokio::task::JoinError;
2use super::*;
3
4impl From<ExampleErrorKind> for PixivError {
5    fn from(value: ExampleErrorKind) -> Self {
6        Self {
7            kind: Box::new(value),
8        }
9    }
10}
11
12impl From<reqwest::Error> for PixivError {
13    fn from(value: reqwest::Error) -> Self {
14        Self {
15            kind: Box::new(ExampleErrorKind::RequestError {
16                message: value.to_string(),
17                context: "".to_string(),
18            }),
19        }
20    }
21}
22
23impl From<std::io::Error> for PixivError {
24    fn from(value: std::io::Error) -> Self {
25        Self {
26            kind: Box::new(ExampleErrorKind::IoError {
27                message: value.to_string(),
28                file: PathBuf::new(),
29            }),
30        }
31    }
32}
33
34impl From<JoinError> for PixivError {
35    fn from(value: JoinError) -> Self {
36        Self {
37            kind: Box::new(ExampleErrorKind::IoError {
38                message: value.to_string(),
39                file: PathBuf::new(),
40            }),
41        }
42    }
43}
44