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 năm trước cách đây
mục cha
commit
0d302516d5

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

@@ -416,7 +416,10 @@ RefPtr<Sheet> Sheet::from_json(const JsonObject& object, Workbook& workbook)
             case Cell::Formula: {
             case Cell::Formula: {
                 auto& interpreter = sheet->interpreter();
                 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()));
                 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);
                 cell = make<Cell>(obj.get("source").to_string(), value_or_error.release_value(), position, *sheet);
                 break;
                 break;
             }
             }