30 lines
886 B
Rust
30 lines
886 B
Rust
|
//
|
||
|
|
||
|
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),
|
||
|
}
|
||
|
impl std::error::Error for Error {}
|
||
|
impl Clone for Error {
|
||
|
fn clone(&self) -> Self {
|
||
|
match self {
|
||
|
Self::Reqwest(req) => Self::Request(req.to_string()),
|
||
|
Self::Request(req) => Self::Request(req.clone()),
|
||
|
Self::UnexpectedMockRequest(_) => todo!(),
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// 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>;
|