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

LibJS: Make Value::to_string_without_side_effects() infallible

Work towards #20449.
This commit is contained in:
Andreas Kling 2023-08-09 08:49:02 +02:00
parent b8f78c0adc
commit 97ebfd9f0f
69 changed files with 182 additions and 182 deletions

View file

@ -41,7 +41,7 @@ void Cell::set_data(JS::Value new_data)
StringBuilder builder;
builder.append(new_data.to_string_without_side_effects().release_value_but_fixme_should_propagate_errors());
builder.append(new_data.to_string_without_side_effects());
m_data = builder.to_deprecated_string();
m_evaluated_data = move(new_data);

View file

@ -68,7 +68,7 @@ Sheet::Sheet(Workbook& workbook)
if (result.is_error()) {
warnln("Spreadsheet: Failed to run runtime code:");
auto thrown_value = *result.throw_completion().value();
warn("Threw: {}", MUST(thrown_value.to_string_without_side_effects()));
warn("Threw: {}", thrown_value.to_string_without_side_effects());
if (thrown_value.is_object() && is<JS::Error>(thrown_value.as_object())) {
auto& error = static_cast<JS::Error const&>(thrown_value.as_object());
warnln(" with message '{}'", error.get_without_side_effects(vm.names.message));
@ -560,7 +560,7 @@ JsonObject Sheet::to_json() const
auto json = realm().global_object().get_without_side_effects("JSON");
auto stringified_or_error = JS::call(vm(), json.as_object().get_without_side_effects("stringify").as_function(), json, it.value->evaluated_data());
VERIFY(!stringified_or_error.is_error());
data.set("value", stringified_or_error.release_value().to_string_without_side_effects().release_value_but_fixme_should_propagate_errors().to_deprecated_string());
data.set("value", stringified_or_error.release_value().to_string_without_side_effects().to_deprecated_string());
} else {
data.set("value", it.value->data());
}
@ -691,7 +691,7 @@ JsonObject Sheet::gather_documentation() const
if (!doc.is_string())
return;
JsonParser parser(doc.to_string_without_side_effects().release_value_but_fixme_should_propagate_errors());
JsonParser parser(doc.to_string_without_side_effects());
auto doc_object = parser.parse();
if (!doc_object.is_error())

View file

@ -33,7 +33,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
auto message = object.get_without_side_effects("message");
auto error = message.to_deprecated_string(vm);
if (error.is_throw_completion())
builder.append(message.to_string_without_side_effects().release_value_but_fixme_should_propagate_errors());
builder.append(message.to_string_without_side_effects());
else
builder.append(error.release_value());
return builder.to_deprecated_string();
@ -120,7 +120,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
auto& error = static_cast<JS::Error&>(object);
auto const& trace = error.traceback();
StringBuilder builder;
builder.appendff("{}\n", error.get_without_side_effects(object.vm().names.message).to_string_without_side_effects().release_value_but_fixme_should_propagate_errors());
builder.appendff("{}\n", error.get_without_side_effects(object.vm().names.message).to_string_without_side_effects());
for (auto const& frame : trace.in_reverse()) {
if (frame.source_range().filename().contains("runtime.js"sv)) {
if (frame.function_name == "<unknown>")