From 587f9af960daa9f003ec9e41751cdc4ce50b87dd Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 15 Nov 2021 01:46:51 +0100 Subject: AK: Make JSON parser return ErrorOr (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. --- Userland/Libraries/LibKeyboard/CharacterMapFile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Userland/Libraries/LibKeyboard') diff --git a/Userland/Libraries/LibKeyboard/CharacterMapFile.cpp b/Userland/Libraries/LibKeyboard/CharacterMapFile.cpp index b36693c008..88f2df9b41 100644 --- a/Userland/Libraries/LibKeyboard/CharacterMapFile.cpp +++ b/Userland/Libraries/LibKeyboard/CharacterMapFile.cpp @@ -31,7 +31,7 @@ Optional CharacterMapFile::load_from_file(const String& filena auto file_contents = file->read_all(); auto json_result = JsonValue::from_string(file_contents); - if (!json_result.has_value()) { + if (json_result.is_error()) { dbgln("Failed to load character map from file {}", path); return {}; } -- cgit v1.2.3