From dac4666ccb64cdec39f88da95b49854448ca0821 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Fri, 24 May 2019 20:32:01 +0300
Subject: [PATCH] Fixes #33 by try catch

---
 components/common/cpp/src/configuration.cpp | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/components/common/cpp/src/configuration.cpp b/components/common/cpp/src/configuration.cpp
index a2674dcb0..45b40da01 100644
--- a/components/common/cpp/src/configuration.cpp
+++ b/components/common/cpp/src/configuration.cpp
@@ -115,10 +115,15 @@ static bool mergeConfig(const string &path) {
 	ifstream i;
 	i.open(path);
 	if (i.is_open()) {
-		json t;
-		i >> t;
-		config.merge_patch(t);
-		return true;
+		try {
+			json t;
+			i >> t;
+			config.merge_patch(t);
+			return true;
+		} catch (json::parse_error& e) {
+			LOG(ERROR) << "Parse error in loading config: "  << e.what();
+			return false;
+		}
 	} else {
 		return false;
 	}
-- 
GitLab