Utilities/lsof: Propagate errors in JSON decoding

This commit is contained in:
creator1creeper1 2021-12-25 16:13:33 +01:00 committed by Andreas Kling
parent fe2ade13e9
commit 904c8634eb
Notes: sideshowbarker 2024-07-17 21:54:33 +09:00

View File

@ -70,7 +70,12 @@ static Vector<OpenFile> 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<OpenFile>();
}
auto json = json_or_error.release_value();
Vector<OpenFile> files;
json.as_array().for_each([pid, &files](const JsonValue& object) {