Skip to main content

x_rs/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum Error {
5    #[error("http request failed / {0}")]
6    Http(#[from] reqwest::Error),
7
8    #[error("json parsing failed / {0}")]
9    Json(#[from] serde_json::Error),
10
11    #[error("io error / {0}")]
12    Io(#[from] std::io::Error),
13
14    #[error("authentication required")]
15    AuthRequired,
16
17    #[error("invalid credentials")]
18    InvalidCredentials,
19
20    #[error("rate limited")]
21    RateLimited(Option<u64>),
22
23    #[error("user not found / {0}")]
24    UserNotFound(String),
25
26    #[error("tweet not found / {0}")]
27    TweetNotFound(String),
28
29    #[error("operation not found / {0}")]
30    OperationNotFound(String),
31
32    #[error("guest token failed")]
33    GuestTokenFailed,
34
35    #[error("session expired")]
36    SessionExpired,
37
38    #[error("blocked")]
39    Blocked,
40
41    #[error("{0}")]
42    Api(String),
43}
44
45pub type Result<T> = std::result::Result<T, Error>;