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

Spreadsheet: No longer use vm.exception() to signal exception state

Instead, use the completions which are returned directly. This means we
no longer have to worry about the global VM state when running code.
This commit is contained in:
davidot 2022-02-07 15:00:40 +01:00 committed by Linus Groh
parent e160f508a8
commit 4ef1e8f226
11 changed files with 98 additions and 97 deletions

View file

@ -28,12 +28,6 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
return String::empty();
Function<String(JS::Value)> to_string_as_exception = [&](JS::Value value) {
ScopeGuard clear_exception {
[&] {
cell->sheet().interpreter().vm().clear_exception();
}
};
StringBuilder builder;
builder.append("Error: "sv);
if (value.is_object()) {
@ -58,8 +52,8 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
};
if (cell->kind() == Spreadsheet::Cell::Formula) {
if (auto exception = cell->exception())
return to_string_as_exception(exception->value());
if (auto opt_throw_value = cell->thrown_value(); opt_throw_value.has_value())
return to_string_as_exception(*opt_throw_value);
}
auto display = cell->typed_display();
@ -86,7 +80,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role)
return {};
if (cell->kind() == Spreadsheet::Cell::Formula) {
if (cell->exception())
if (cell->thrown_value().has_value())
return Color(Color::Red);
}