Skip to content

Commit

Permalink
LibWeb/ResourceLoader: Report file: errors as "network errors"
Browse files Browse the repository at this point in the history
This triggers the generated error page which is more informative.
  • Loading branch information
circl-lastname authored and ADKaster committed Jul 5, 2024
1 parent e35b055 commit 91e3ef6
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down

0 comments on commit 91e3ef6

Please sign in to comment.