LibWeb/ResourceLoader: Report file: errors as "network errors"

This triggers the generated error page which is more informative.
This commit is contained in:
circl 2024-06-18 18:33:16 +02:00 committed by Andrew Kaster
parent e35b055192
commit 91e3ef6dbf
Notes: sideshowbarker 2024-07-17 08:42:05 +09:00

View File

@ -334,10 +334,8 @@ void ResourceLoader::load(LoadRequest& request, SuccessCallback success_callback
if (file_or_error.is_error()) {
log_failure(request, file_or_error.error());
if (error_callback) {
auto status = file_or_error.error().code() == ENOENT ? 404u : 500u;
error_callback(ByteString::formatted("{}", file_or_error.error()), status, {}, {});
}
if (error_callback)
error_callback(ByteString::formatted("{}", file_or_error.error()), {}, {}, {});
return;
}
@ -354,7 +352,7 @@ void ResourceLoader::load(LoadRequest& request, SuccessCallback success_callback
if (st_or_error.is_error()) {
log_failure(request, st_or_error.error());
if (error_callback)
error_callback(ByteString::formatted("{}", st_or_error.error()), 500u, {}, {});
error_callback(ByteString::formatted("{}", st_or_error.error()), {}, {}, {});
return;
}
@ -363,7 +361,7 @@ void ResourceLoader::load(LoadRequest& request, SuccessCallback success_callback
if (maybe_file.is_error()) {
log_failure(request, maybe_file.error());
if (error_callback)
error_callback(ByteString::formatted("{}", maybe_file.error()), 500u, {}, {});
error_callback(ByteString::formatted("{}", maybe_file.error()), {}, {}, {});
return;
}
@ -372,7 +370,7 @@ void ResourceLoader::load(LoadRequest& request, SuccessCallback success_callback
if (maybe_data.is_error()) {
log_failure(request, maybe_data.error());
if (error_callback)
error_callback(ByteString::formatted("{}", maybe_data.error()), 500u, {}, {});
error_callback(ByteString::formatted("{}", maybe_data.error()), {}, {}, {});
return;
}