1use std::fmt::{Debug, Formatter};
2use std::error::Error;
3use std::fmt::Display;
4use std::path::PathBuf;
5
6mod display;
7mod convert;
8
9pub type Result<T> = std::result::Result<T, PixivError>;
11
12#[derive(Clone)]
14pub struct PixivError {
15 kind: Box<ExampleErrorKind>,
16}
17
18#[derive(Debug, Clone)]
20pub enum ExampleErrorKind {
21 IoError {
22 message: String,
23 file: PathBuf,
24 },
25 RequestError {
26 message: String,
28 context: String,
29 },
30 UnknownError,
32}
33
34
35impl PixivError {
36 pub fn request_error(message: impl Into<String>, context: impl Into<String>) -> Self {
37 Self {
38 kind: Box::new(ExampleErrorKind::RequestError {
39 message: message.into(),
40 context: context.into(),
41 }),
42 }
43 }
44}