diff options
author | Timothy Flynn <trflynn89@pm.me> | 2023-04-04 16:12:42 -0400 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-04-04 22:41:20 +0100 |
commit | 69e8216f2c5310ca68409ecaf501266da43f14ba (patch) | |
tree | 152da2a20782fab0c395ad6a5d6851106289eb07 | |
parent | ddb4137ed4f98cd82d985813a292af4cc119d4f6 (diff) | |
download | serenity-69e8216f2c5310ca68409ecaf501266da43f14ba.zip |
LibWeb: Do not use OS error codes in the error callback for file:// URLs
The error code passed here is expected to be an HTTP error code. Passing
errno codes does not make sense in that context.
-rw-r--r-- | Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp index 01edc9163f..fffc0fff11 100644 --- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp @@ -244,8 +244,10 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has if (file_or_error.is_error()) { log_failure(request, file_or_error.error()); - if (error_callback) - error_callback(DeprecatedString::formatted("{}", file_or_error.error()), file_or_error.error().code()); + if (error_callback) { + auto status = file_or_error.error().code() == ENOENT ? 404u : 500u; + error_callback(DeprecatedString::formatted("{}", file_or_error.error()), status); + } return; } @@ -255,7 +257,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has if (maybe_file.is_error()) { log_failure(request, maybe_file.error()); if (error_callback) - error_callback(DeprecatedString::formatted("{}", maybe_file.error()), maybe_file.error().code()); + error_callback(DeprecatedString::formatted("{}", maybe_file.error()), 500u); return; } @@ -264,7 +266,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has if (maybe_data.is_error()) { log_failure(request, maybe_data.error()); if (error_callback) - error_callback(DeprecatedString::formatted("{}", maybe_data.error()), maybe_data.error().code()); + error_callback(DeprecatedString::formatted("{}", maybe_data.error()), 500u); return; } auto data = maybe_data.release_value(); |