From 067e32c0234b90f2ccc21c94c39f04f73d43c719 Mon Sep 17 00:00:00 2001 From: creator1creeper1 Date: Sat, 25 Dec 2021 16:41:14 +0100 Subject: [PATCH] Utilities/netstat: Propagate errors in JSON decoding --- Userland/Utilities/netstat.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Userland/Utilities/netstat.cpp b/Userland/Utilities/netstat.cpp index 03bd277e9f..70f787cc1d 100644 --- a/Userland/Utilities/netstat.cpp +++ b/Userland/Utilities/netstat.cpp @@ -139,7 +139,12 @@ ErrorOr serenity_main(Main::Arguments arguments) } auto file_contents = file->read_all(); - auto json = JsonValue::from_string(file_contents).release_value_but_fixme_should_propagate_errors(); + auto json_or_error = JsonValue::from_string(file_contents); + if (json_or_error.is_error()) { + warnln("Error: {}", json_or_error.error()); + return 1; + } + auto json = json_or_error.release_value(); Vector sorted_regions = json.as_array().values(); quick_sort(sorted_regions, [](auto& a, auto& b) {