2024-11-04 10:22:31 +00:00
|
|
|
//
|
|
|
|
use derive_more::derive::From;
|
|
|
|
|
|
|
|
/// Represents a error accessing the network.
|
|
|
|
#[derive(Debug, From, derive_more::Display)]
|
|
|
|
pub enum Error {
|
|
|
|
Reqwest(reqwest::Error),
|
|
|
|
Request(String),
|
|
|
|
#[display("Unexpected request: {0}", 0.to_string())]
|
|
|
|
UnexpectedMockRequest(reqwest::Request),
|
2024-11-09 12:13:06 +00:00
|
|
|
RwLockLocked,
|
2024-11-10 09:44:30 +00:00
|
|
|
Http(http::Error),
|
|
|
|
NetIsNotAMock,
|
2024-11-04 10:22:31 +00:00
|
|
|
}
|
|
|
|
impl std::error::Error for Error {}
|
|
|
|
impl Clone for Error {
|
|
|
|
fn clone(&self) -> Self {
|
|
|
|
match self {
|
|
|
|
Self::Reqwest(req) => Self::Request(req.to_string()),
|
2024-11-09 12:13:06 +00:00
|
|
|
err => err.clone(),
|
2024-11-04 10:22:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Represents a success or a failure.
|
|
|
|
///
|
|
|
|
/// Any failure is related to `std::io`, a Path Traversal
|
|
|
|
/// (i.e. trying to escape the base of the `FileSystem`),
|
|
|
|
/// or attempting to use a file as a directory or /vise versa/.
|
|
|
|
pub type Result<T> = core::result::Result<T, Error>;
|