Skip to main content

fetchr_http/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum HttpError {
5    #[error("HTTP request failed: {0}")]
6    Reqwest(#[from] reqwest::Error),
7
8    #[error("Invalid URL '{0}'")]
9    InvalidUrl(String),
10
11    #[error("Server returned unsuccessful status code {status}: {message}")]
12    HttpStatus { status: u16, message: String },
13
14    #[error("Range request failed or not supported by server")]
15    RangeNotSupported,
16
17    #[error("Header parsing error: {0}")]
18    HeaderParse(String),
19}
20
21pub type Result<T> = std::result::Result<T, HttpError>;