From 7898e200b8973cf78b1727ef2e0f730594c03d29 Mon Sep 17 00:00:00 2001
From: Federico Montesino Pouzols <federico.montesino-pouzols@stfc.ac.uk>
Date: Tue, 13 Oct 2015 18:03:00 +0100
Subject: [PATCH] check retval from json parser + fix test example, 1311473, re
 #13951

---
 Framework/DataHandling/src/CheckMantidVersion.cpp    | 9 ++++++++-
 Framework/DataHandling/test/CheckMantidVersionTest.h | 3 ++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Framework/DataHandling/src/CheckMantidVersion.cpp b/Framework/DataHandling/src/CheckMantidVersion.cpp
index 30a620c6079..2748bf49ba2 100644
--- a/Framework/DataHandling/src/CheckMantidVersion.cpp
+++ b/Framework/DataHandling/src/CheckMantidVersion.cpp
@@ -107,7 +107,14 @@ void CheckMantidVersion::exec() {
   if (!json.empty()) {
     Json::Reader r;
     Json::Value root;
-    r.parse(json, root);
+    bool parseOK = r.parse(json, root);
+    if (!parseOK) {
+      g_log.error() << "Error trying to parse this JSON string from GitHub: "
+                    << json << std::endl;
+      throw std::runtime_error("Error found when parsing version information "
+                               "retrieved from GitHub as a JSON string." +
+                               r.getFormattedErrorMessages());
+    }
 
     std::string gitHubVersionTag = root["tag_name"].asString();
     mostRecentVersion = cleanVersionTag(gitHubVersionTag);
diff --git a/Framework/DataHandling/test/CheckMantidVersionTest.h b/Framework/DataHandling/test/CheckMantidVersionTest.h
index d6c1e17a95d..d7cf6155fca 100644
--- a/Framework/DataHandling/test/CheckMantidVersionTest.h
+++ b/Framework/DataHandling/test/CheckMantidVersionTest.h
@@ -77,7 +77,8 @@ private:
         "\"https://api.github.com/users/peterfpeterson/received_events\",\n"
         "    \"type\": \"User\",\n"
         "    \"site_admin\": false\n"
-        "  }";
+        "  }\n"
+        "}";
 
     return outputString;
   }
-- 
GitLab