From 904c8634eb9d7048690caf3b5529fc16ddc0f07d Mon Sep 17 00:00:00 2001 From: creator1creeper1 Date: Sat, 25 Dec 2021 16:13:33 +0100 Subject: [PATCH] Utilities/lsof: Propagate errors in JSON decoding --- Userland/Utilities/lsof.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Userland/Utilities/lsof.cpp b/Userland/Utilities/lsof.cpp index 8690ed7018..2646173dac 100644 --- a/Userland/Utilities/lsof.cpp +++ b/Userland/Utilities/lsof.cpp @@ -70,7 +70,12 @@ static Vector get_open_files_by_pid(pid_t pid) } auto data = file.value()->read_all(); - auto json = JsonValue::from_string(data).release_value_but_fixme_should_propagate_errors(); + auto json_or_error = JsonValue::from_string(data); + if (json_or_error.is_error()) { + outln("lsof: {}", json_or_error.error()); + return Vector(); + } + auto json = json_or_error.release_value(); Vector files; json.as_array().for_each([pid, &files](const JsonValue& object) {