mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
register redirect failure as global
This commit is contained in:
parent
e48d425672
commit
8091dd6ace
3 changed files with 15 additions and 11 deletions
|
|
@ -34,10 +34,10 @@ impl Status {
|
|||
}
|
||||
|
||||
/// 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 {
|
||||
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`
|
||||
pub enum Failure {
|
||||
/// Redirection count limit reached by protocol driver or global settings
|
||||
RedirectLimit { count: usize },
|
||||
RedirectLimit { count: usize, is_global: bool },
|
||||
}
|
||||
|
||||
impl Failure {
|
||||
// Constructors
|
||||
|
||||
/// Create new `Self::RedirectLimit`
|
||||
pub fn redirect_limit(count: usize) -> Self {
|
||||
Self::RedirectLimit { count }
|
||||
pub fn redirect_limit(count: usize, is_global: bool) -> Self {
|
||||
Self::RedirectLimit { count, is_global }
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Failure {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result {
|
||||
match self {
|
||||
Self::RedirectLimit { count } => {
|
||||
write!(
|
||||
f,
|
||||
"Redirection limit ({count}) reached by protocol driver or global settings"
|
||||
)
|
||||
Self::RedirectLimit { count, is_global } => {
|
||||
if *is_global {
|
||||
write!(f, "Redirection limit ({count}) reached by global settings")
|
||||
} else {
|
||||
write!(
|
||||
f,
|
||||
"Redirection limit ({count}) reached by protocol restrictions"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue