ckpool_api/
error.rs

1//! Error
2
3use std::fmt;
4
5use url::ParseError;
6
7/// CKPool error
8#[derive(Debug)]
9pub enum Error {
10    /// URL parse error
11    Url(ParseError),
12    /// Reqwest error
13    Reqwest(reqwest::Error),
14    /// User not found
15    UserNotFound,
16}
17
18impl std::error::Error for Error {}
19
20impl fmt::Display for Error {
21    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22        match self {
23            Self::Url(e) => write!(f, "{e}"),
24            Self::Reqwest(e) => write!(f, "{e}"),
25            Self::UserNotFound => write!(f, "User not found"),
26        }
27    }
28}
29
30impl From<ParseError> for Error {
31    fn from(e: ParseError) -> Self {
32        Self::Url(e)
33    }
34}
35
36impl From<reqwest::Error> for Error {
37    fn from(e: reqwest::Error) -> Self {
38        Self::Reqwest(e)
39    }
40}