1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 11:47:35 +00:00

LibWeb/Fetch: Store Response error message as a String{,View} variant

The majority of error strings are StringView literals, and it seems
silly to require heap-allocating strings for these.

This idea is stolen from a recent change in fd1fbad :^)
This commit is contained in:
Linus Groh 2023-03-03 18:02:43 +00:00
parent 03f32bdf86
commit 1032ac2453
5 changed files with 45 additions and 37 deletions

View file

@ -99,8 +99,8 @@ JS::NonnullGCPtr<JS::Promise> fetch_impl(JS::VM& vm, RequestInfo const& input, R
// 3. If response is a network error, then reject p with a TypeError and abort these steps.
if (response->is_network_error()) {
auto message = response->network_error_message().value_or("Response is a network error"_string.release_value_but_fixme_should_propagate_errors());
WebIDL::reject_promise(vm, promise_capability, JS::TypeError::create(relevant_realm, move(message)));
auto message = response->network_error_message().value_or("Response is a network error"sv);
WebIDL::reject_promise(vm, promise_capability, JS::TypeError::create(relevant_realm, message).release_allocated_value_but_fixme_should_propagate_errors());
return;
}