Debug Implementation for NetworkError

Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
This commit is contained in:
Uthman Yahaya Baba 2025-04-24 01:27:24 +01:00
parent 1b396e535f
commit 545364c636

View file

@ -5,7 +5,7 @@
#![deny(unsafe_code)]
use std::collections::HashMap;
use std::fmt::{Debug, Display, Formatter};
use std::fmt::{self, Debug, Display};
use std::sync::{LazyLock, OnceLock};
use std::thread;
@ -924,7 +924,7 @@ pub enum CookieSource {
}
/// Network errors that have to be exported out of the loaders
#[derive(Clone, Debug, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)]
#[derive(Clone, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)]
pub enum NetworkError {
/// Could be any of the internal errors, like unsupported scheme, connection errors, etc.
Internal(String),
@ -959,6 +959,7 @@ pub enum NetworkError {
impl fmt::Debug for NetworkError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
NetworkError::Internal(s) => write!(f, "{}", s),
NetworkError::UnsupportedScheme => write!(f, "Unsupported scheme"),
NetworkError::CorsGeneral => write!(f, "CORS check failed"),
NetworkError::CrossOriginResponse => write!(f, "Cross-origin response"),