1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! Error types for the crates.io API client.
/// Errors returned by the crates.io API client.
#[derive(Debug, thiserror::Error)]
pub enum Error {
/// HTTP transport error.
#[error("HTTP error: {0}")]
Http(#[from] reqwest::Error),
/// Resource not found (404).
#[error("not found: {0}")]
NotFound(String),
/// Permission denied (403).
#[error("permission denied")]
PermissionDenied,
/// Server returned an error status.
#[error("API error ({status}): {message}")]
Api { status: u16, message: String },
/// Rate limited by the server (429).
#[error("rate limited")]
RateLimited,
/// Authentication required for this endpoint.
#[error("authentication required")]
AuthRequired,
/// Unauthorized (401).
#[error("unauthorized")]
Unauthorized,
/// JSON serialization error.
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
}