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
/// An error generated by user input
#[derive(Debug, serde::Serialize)]
#[serde(rename_all = "snake_case")]
pub enum UserError {
    /// Cannot look up the crate    
    CannotLookup {
        /// Name of the crate
        name: String,
        /// Version of the crate
        version: Option<String>,
        /// Error display
        error: String,
    },
    /// No versions found for the crate    
    NoVersions {
        /// Name of the crate
        name: String,
    },
    /// An invalid version was specified for the crate    
    InvalidVersion {
        /// Name of the crate
        name: String,
        /// Version of the crate
        version: String,
    },
}

/// An error generated internally (not caused by the user).
#[derive(Debug, thiserror::Error)]
pub enum InternalError {
    /// Failed to de/serialize some json
    #[error("json deserialization error: {0}")]
    Json(#[from] serde_json::Error),
    /// Failed to do an HTTP request
    #[error("http get error: {0}")]
    Http(#[from] attohttpc::Error),
}