diff options
author | Andreas Kling <kling@serenityos.org> | 2021-11-15 01:46:51 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-17 00:21:10 +0100 |
commit | 587f9af960daa9f003ec9e41751cdc4ce50b87dd (patch) | |
tree | 41bc5b51741dffcc23e3e4b63d4c17a37e2e03d7 /Userland/Applications/Spreadsheet | |
parent | 304c03f457e294a3d756860325d93b809f50f7a6 (diff) | |
download | serenity-587f9af960daa9f003ec9e41751cdc4ce50b87dd.zip |
AK: Make JSON parser return ErrorOr<JsonValue> (instead of Optional)
Also add slightly richer parse errors now that we can include a string
literal with returned errors.
This will allow us to use TRY() when working with JSON data.
Diffstat (limited to 'Userland/Applications/Spreadsheet')
-rw-r--r-- | Userland/Applications/Spreadsheet/ImportDialog.cpp | 2 | ||||
-rw-r--r-- | Userland/Applications/Spreadsheet/Spreadsheet.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Applications/Spreadsheet/ImportDialog.cpp b/Userland/Applications/Spreadsheet/ImportDialog.cpp index 3c19bbaf27..2c646bf41b 100644 --- a/Userland/Applications/Spreadsheet/ImportDialog.cpp +++ b/Userland/Applications/Spreadsheet/ImportDialog.cpp @@ -209,7 +209,7 @@ Result<NonnullRefPtrVector<Sheet>, String> ImportDialog::make_and_run_for(String auto import_worksheet = [&]() -> Result<NonnullRefPtrVector<Sheet>, String> { auto json_value_option = JsonParser(file.read_all()).parse(); - if (!json_value_option.has_value()) { + if (json_value_option.is_error()) { StringBuilder sb; sb.append("Failed to parse "); sb.append(file.filename()); diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp index 88f054652b..eeeee7670b 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp +++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp @@ -667,7 +667,7 @@ JsonObject Sheet::gather_documentation() const JsonParser parser(doc.to_string_without_side_effects()); auto doc_object = parser.parse(); - if (doc_object.has_value()) + if (!doc_object.is_error()) object.set(it.key.to_display_string(), doc_object.value()); else dbgln("Sheet::gather_documentation(): Failed to parse the documentation for '{}'!", it.key.to_display_string()); |