Browse Source

Spreadsheet: Skip over "invalid" saved cell values

These can be generated by saving something that's not serialisable (e.g.
functions), skip over them and let the load logic reevaluate them when
needed.
Ali Mohammad Pur 3 years ago
parent
commit
0d302516d5
1 changed files with 4 additions and 1 deletions
  1. 4 1
      Userland/Applications/Spreadsheet/Spreadsheet.cpp

+ 4 - 1
Userland/Applications/Spreadsheet/Spreadsheet.cpp

@@ -416,7 +416,10 @@ RefPtr<Sheet> Sheet::from_json(const JsonObject& object, Workbook& workbook)
             case Cell::Formula: {
                 auto& interpreter = sheet->interpreter();
                 auto value_or_error = JS::call(interpreter.global_object(), parse_function, json, JS::js_string(interpreter.heap(), obj.get("value").as_string()));
-                VERIFY(!value_or_error.is_error());
+                if (value_or_error.is_error()) {
+                    warnln("Failed to load previous value for cell {}, leaving as undefined", position.to_cell_identifier(sheet));
+                    value_or_error = JS::js_undefined();
+                }
                 cell = make<Cell>(obj.get("source").to_string(), value_or_error.release_value(), position, *sheet);
                 break;
             }