mirror of
https://github.com/servo/servo.git
synced 2025-08-11 00:15:32 +01:00
Debug Implementation for NetworkError
Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
This commit is contained in:
parent
a7fe7cad68
commit
1b396e535f
2 changed files with 35 additions and 2 deletions
|
@ -227,7 +227,7 @@ impl FetchResponseListener for FetchContext {
|
|||
// Step 4.1
|
||||
Err(_) => {
|
||||
promise.reject_error(
|
||||
Error::Type("Network error occurred".to_string()),
|
||||
Error::Type(format!("Network error: {:?}", error)),
|
||||
CanGc::note(),
|
||||
);
|
||||
self.fetch_promise = Some(TrustedPromise::new(promise));
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#![deny(unsafe_code)]
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::Display;
|
||||
use std::fmt::{Debug, Display, Formatter};
|
||||
use std::sync::{LazyLock, OnceLock};
|
||||
use std::thread;
|
||||
|
||||
|
@ -956,6 +956,39 @@ pub enum NetworkError {
|
|||
LocalDirectoryError,
|
||||
}
|
||||
|
||||
impl fmt::Debug for NetworkError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
NetworkError::UnsupportedScheme => write!(f, "Unsupported scheme"),
|
||||
NetworkError::CorsGeneral => write!(f, "CORS check failed"),
|
||||
NetworkError::CrossOriginResponse => write!(f, "Cross-origin response"),
|
||||
NetworkError::CorsCredentials => write!(f, "Cross-origin credentials check failed"),
|
||||
NetworkError::CorsAllowMethods => write!(f, "CORS ACAM check failed"),
|
||||
NetworkError::CorsAllowHeaders => write!(f, "CORS ACAH check failed"),
|
||||
NetworkError::CorsMethod => write!(f, "CORS method check failed"),
|
||||
NetworkError::CorsAuthorization => write!(f, "CORS authorization check failed"),
|
||||
NetworkError::CorsHeaders => write!(f, "CORS headers check failed"),
|
||||
NetworkError::ConnectionFailure => write!(f, "Request failed"),
|
||||
NetworkError::RedirectError => write!(f, "Too many redirects"),
|
||||
NetworkError::InvalidMethod => write!(f, "Unexpected method"),
|
||||
NetworkError::ResourceError => write!(f, "Resource access failed"),
|
||||
NetworkError::ContentSecurityPolicy => write!(f, "Blocked by Content-Security-Policy"),
|
||||
NetworkError::Nosniff => write!(f, "Blocked by nosniff"),
|
||||
NetworkError::MimeType => write!(f, "Blocked by mime type"),
|
||||
NetworkError::SubresourceIntegrity => {
|
||||
write!(f, "Subresource integrity validation failed")
|
||||
},
|
||||
NetworkError::MixedContent => write!(f, "Blocked as mixed content"),
|
||||
NetworkError::CacheError => write!(f, "Cache error"),
|
||||
NetworkError::InvalidPort => write!(f, "Request attempted on bad port"),
|
||||
NetworkError::LocalDirectoryError => write!(f, "Local directory access failed"),
|
||||
NetworkError::LoadCancelled => write!(f, "Load cancelled"),
|
||||
NetworkError::SslValidation(s, _) => write!(f, "SSL validation error: {}", s),
|
||||
NetworkError::Crash(s) => write!(f, "Crash: {}", s),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl NetworkError {
|
||||
pub fn from_hyper_error(error: &HyperError, certificate: Option<CertificateDer>) -> Self {
|
||||
let error_string = error.to_string();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue