mirror of
https://github.com/Hopiu/lychee.git
synced 2026-04-28 08:54:46 +00:00
Remove hardcoded rule for handling erroneous status codes differently
This commit is contained in:
parent
31b2525a8d
commit
4e5043a3c3
2 changed files with 7 additions and 6 deletions
|
|
@ -1,3 +1,4 @@
|
|||
use http::StatusCode;
|
||||
use serde::{Serialize, Serializer};
|
||||
use std::error::Error;
|
||||
use std::hash::Hash;
|
||||
|
|
@ -144,6 +145,10 @@ pub enum ErrorKind {
|
|||
#[error("Invalid status code: {0}")]
|
||||
InvalidStatusCode(u16),
|
||||
|
||||
/// The given status code might be considered valid but was rejected as because of the configuration
|
||||
#[error("Rejected status code: {0}")]
|
||||
RejectedStatusCode(StatusCode),
|
||||
|
||||
/// Regex error
|
||||
#[error("Error when using regex engine: {0}")]
|
||||
Regex(#[from] regex::Error),
|
||||
|
|
@ -322,6 +327,7 @@ impl Hash for ErrorKind {
|
|||
Self::InvalidHeader(e) => e.to_string().hash(state),
|
||||
Self::InvalidGlobPattern(e) => e.to_string().hash(state),
|
||||
Self::InvalidStatusCode(c) => c.hash(state),
|
||||
Self::RejectedStatusCode(c) => c.hash(state),
|
||||
Self::Channel(e) => e.to_string().hash(state),
|
||||
Self::MissingGitHubToken | Self::InvalidUrlHost => {
|
||||
std::mem::discriminant(self).hash(state);
|
||||
|
|
|
|||
|
|
@ -89,12 +89,7 @@ impl Status {
|
|||
if let Some(true) = accepted.map(|a| a.contains(&code)) {
|
||||
Self::Ok(code)
|
||||
} else {
|
||||
match response.error_for_status_ref() {
|
||||
Ok(_) if code.is_success() => Self::Ok(code),
|
||||
Ok(_) if code.is_redirection() => Self::Redirected(code),
|
||||
Ok(_) => Self::UnknownStatusCode(code),
|
||||
Err(e) => e.into(),
|
||||
}
|
||||
Self::Error(ErrorKind::RejectedStatusCode(code))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue