From 9c832e3b0fc0df295cc14e3e11b46a8e50acd153 Mon Sep 17 00:00:00 2001 From: creator1creeper1 Date: Sat, 25 Dec 2021 16:38:33 +0100 Subject: [PATCH] Utilities/ifconfig: Propagate errors in JSON decoding --- Userland/Utilities/ifconfig.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Userland/Utilities/ifconfig.cpp b/Userland/Utilities/ifconfig.cpp index 5fc18ee3b4..b81770dcce 100644 --- a/Userland/Utilities/ifconfig.cpp +++ b/Userland/Utilities/ifconfig.cpp @@ -45,7 +45,12 @@ int main(int argc, char** argv) } 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()) { + outln("Failed to decode JSON: {}", json_or_error.error()); + return 1; + } + auto json = json_or_error.release_value(); json.as_array().for_each([](auto& value) { auto& if_object = value.as_object();