From bf2343015ec3459be3962c0655afdeaf2670e152 Mon Sep 17 00:00:00 2001 From: Alexander Shaduri Date: Thu, 2 May 2024 13:47:14 +0400 Subject: [PATCH] Avoid unnecessary exceptions when reading config file. --- src/applib/storage_settings.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/applib/storage_settings.h b/src/applib/storage_settings.h index 1f42630..f4520d2 100644 --- a/src/applib/storage_settings.h +++ b/src/applib/storage_settings.h @@ -60,10 +60,12 @@ inline void from_json(const rconfig::json& j, AppDeviceOptionMap& devmap) { for (const auto& obj : j) { try { - devmap.value.insert_or_assign( - {obj.at("device").get(), obj.at("type").get()}, - obj.at("options").get() - ); + if (obj.contains("device") && obj.contains("type") && obj.contains("options")) { + devmap.value.insert_or_assign( + {obj.at("device").get(), obj.at("type").get()}, + obj.at("options").get() + ); + } } catch(std::exception& e) { // ignore "not found"