mirrors_arch/errors/
mod.rs

1use reqwest::StatusCode;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5/// Error type definitions returned by the crate
6pub enum Error {
7    /// The connection could not be made (perhaps a network error is
8    /// the cause)
9    #[error("could not establish connection")]
10    Connection(#[from] reqwest::Error),
11    /// The response could not be parsed to an internal type
12    #[error("could not parse response")]
13    Parse(#[from] serde_json::Error),
14    /// The mirror could not be rated
15    #[error("could not find file (expected {qualified_url:?}, from {url:?}), server returned {status_code:?}")]
16    Rate {
17        /// The URL including the filepath that was sent in the request
18        qualified_url: String,
19        /// The URL of the particular mirror
20        url: String,
21        /// The status code returned by the server
22        status_code: StatusCode,
23    },
24    #[error("could not build request {0}")]
25    /// There was an error performing the request
26    Request(String),
27    /// There was an error performing the request
28    #[cfg(feature = "time")]
29    #[error("could not parse time")]
30    TimeError(#[from] chrono::ParseError),
31}