Replace NetworkError::Internal with structured enum variants for calls with literal strings (#36599)

Replace NetworkError::Internal with structured enum variants
- Adds
UnsupportedScheme,CorsViolation,ConnectionFailure,Timeout,RedirectError,InvalidMethod,ResourceError,SecurityBlock,MixedContent,CacheError,InvalidPort,
LocalDirectoryError, variants in NetworkError enum.
- Refactored the usage of NetworkError::Internal(String) to use the
appropriate new variant

Testing: Changes does not require test.
Fixes: https://github.com/servo/servo/issues/36434

---------

Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
Signed-off-by: Usman Yahaya Baba <91813795+uthmaniv@users.noreply.github.com>
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Co-authored-by: Tim van der Lippe <tvanderlippe@gmail.com>
This commit is contained in:
Usman Yahaya Baba
2026-01-02 11:28:17 +01:00
committed by GitHub
parent df9877a94c
commit 6decaaefa9
18 changed files with 158 additions and 122 deletions

View File

@@ -353,13 +353,13 @@ impl FetchResponseListener for ClassicContext {
self.status = {
if status.is_error() {
Err(NetworkError::Internal(
Err(NetworkError::ResourceLoadError(
"No http status code received".to_owned(),
))
} else if status.is_success() {
Ok(())
} else {
Err(NetworkError::Internal(format!(
Err(NetworkError::ResourceLoadError(format!(
"HTTP error code {}",
status.code()
)))