mastodon_api/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum MastodonError {
5    #[error("HTTP request failed: {0}")]
6    Reqwest(#[from] reqwest::Error),
7
8    #[error("URL parsing failed: {0}")]
9    Url(#[from] url::ParseError),
10
11    #[error("JSON serialization/deserialization failed: {0}")]
12    Serde(#[from] serde_json::Error),
13
14    #[error("API error (status {status}): {message}")]
15    ApiError {
16        status: reqwest::StatusCode,
17        message: String,
18    },
19
20    #[error("Authentication failed: {0}")]
21    AuthError(String),
22
23    #[error("Rate limit exceeded. Retry after: {0}")]
24    RateLimit(String),
25
26    #[error("Custom error: {0}")]
27    Custom(String),
28}
29
30pub type Result<T> = std::result::Result<T, MastodonError>;