From b9b37f4f2e29161971bf2633b7b78c75638a3393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Ta=C5=82ajko?= Date: Tue, 13 Feb 2018 14:31:16 +0100 Subject: [PATCH 1/2] Log a warning when parsing of the config file failed --- src/SSEConfig.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/SSEConfig.cpp b/src/SSEConfig.cpp index ce048bf..bc2df32 100644 --- a/src/SSEConfig.cpp +++ b/src/SSEConfig.cpp @@ -70,7 +70,9 @@ bool SSEConfig::load(const char *file) { // Read config file. try { boost::property_tree::read_json(file, pt); - } catch (...) {} + } catch (boost::property_tree::ptree_error& e) { + LOG(WARNING) << "Error during loading config file: " << e.what(); + } // Populate ConfigMap. BOOST_FOREACH(ConfigMap_t::value_type &element, ConfigMap) { From a1cc276d071714f16999681f75a7bf8296399ac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Ta=C5=82ajko?= Date: Wed, 14 Feb 2018 14:01:53 +0100 Subject: [PATCH 2/2] Instead of warning terminate the app when config file is invalid --- src/SSEConfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SSEConfig.cpp b/src/SSEConfig.cpp index bc2df32..2f9d2e5 100644 --- a/src/SSEConfig.cpp +++ b/src/SSEConfig.cpp @@ -71,7 +71,7 @@ bool SSEConfig::load(const char *file) { try { boost::property_tree::read_json(file, pt); } catch (boost::property_tree::ptree_error& e) { - LOG(WARNING) << "Error during loading config file: " << e.what(); + LOG(FATAL) << "Error during loading config file: " << e.what(); } // Populate ConfigMap.