mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-26 02:54:15 +00:00
register redirect failure as global
This commit is contained in:
parent
e48d425672
commit
8091dd6ace
@ -81,7 +81,7 @@ impl Client {
|
|||||||
// * this condition just to make sure that client will never stuck by driver implementation issue
|
// * this condition just to make sure that client will never stuck by driver implementation issue
|
||||||
if self.redirect.count() > redirect::LIMIT {
|
if self.redirect.count() > redirect::LIMIT {
|
||||||
self.status
|
self.status
|
||||||
.replace(Status::failure_redirect_limit(redirect::LIMIT));
|
.replace(Status::failure_redirect_limit(redirect::LIMIT, true));
|
||||||
// @TODO return;
|
// @TODO return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,10 +34,10 @@ impl Status {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create new `Self::Failure` as `Failure::RedirectLimit`
|
/// Create new `Self::Failure` as `Failure::RedirectLimit`
|
||||||
pub fn failure_redirect_limit(count: usize) -> Self {
|
pub fn failure_redirect_limit(count: usize, is_global: bool) -> Self {
|
||||||
Self::Failure {
|
Self::Failure {
|
||||||
event: now(),
|
event: now(),
|
||||||
failure: Failure::redirect_limit(count),
|
failure: Failure::redirect_limit(count, is_global),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,26 +4,30 @@ use std::fmt::{Display, Formatter, Result};
|
|||||||
/// Local `Failure` status for `Client`
|
/// Local `Failure` status for `Client`
|
||||||
pub enum Failure {
|
pub enum Failure {
|
||||||
/// Redirection count limit reached by protocol driver or global settings
|
/// Redirection count limit reached by protocol driver or global settings
|
||||||
RedirectLimit { count: usize },
|
RedirectLimit { count: usize, is_global: bool },
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Failure {
|
impl Failure {
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
/// Create new `Self::RedirectLimit`
|
/// Create new `Self::RedirectLimit`
|
||||||
pub fn redirect_limit(count: usize) -> Self {
|
pub fn redirect_limit(count: usize, is_global: bool) -> Self {
|
||||||
Self::RedirectLimit { count }
|
Self::RedirectLimit { count, is_global }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Failure {
|
impl Display for Failure {
|
||||||
fn fmt(&self, f: &mut Formatter) -> Result {
|
fn fmt(&self, f: &mut Formatter) -> Result {
|
||||||
match self {
|
match self {
|
||||||
Self::RedirectLimit { count } => {
|
Self::RedirectLimit { count, is_global } => {
|
||||||
write!(
|
if *is_global {
|
||||||
f,
|
write!(f, "Redirection limit ({count}) reached by global settings")
|
||||||
"Redirection limit ({count}) reached by protocol driver or global settings"
|
} else {
|
||||||
)
|
write!(
|
||||||
|
f,
|
||||||
|
"Redirection limit ({count}) reached by protocol restrictions"
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user