From 94550d97c5955ff052276e3cf8e1041f321b7ba1 Mon Sep 17 00:00:00 2001
From: Roman Tolchenov <roman.tolchenov@stfc.ac.uk>
Date: Tue, 21 Dec 2010 11:25:15 +0000
Subject: [PATCH] Fixed the particular issue of python crashing, but it is not
 clear for me why Mantid should work at all without Mantid.properties file. re
 #1594

---
 Code/Mantid/Kernel/src/ConfigService.cpp | 60 ++++++++++++++----------
 1 file changed, 35 insertions(+), 25 deletions(-)

diff --git a/Code/Mantid/Kernel/src/ConfigService.cpp b/Code/Mantid/Kernel/src/ConfigService.cpp
index 9d3bd852692..2ba4924d366 100644
--- a/Code/Mantid/Kernel/src/ConfigService.cpp
+++ b/Code/Mantid/Kernel/src/ConfigService.cpp
@@ -920,41 +920,51 @@ void ConfigServiceImpl::updateFacilities(const std::string& fName)
   // Set up the DOM parser and parse xml file
   Poco::XML::DOMParser pParser;
   Poco::XML::Document* pDoc;
+
   try
   {
-    pDoc = pParser.parse(fileName);
-  } catch (...)
-  {
-    g_log.error("Unable to parse file " + fileName);
-    throw Kernel::Exception::FileError("Unable to parse file:", fileName);
-  }
-  // Get pointer to root element
-  Poco::XML::Element* pRootElem = pDoc->documentElement();
-  if (!pRootElem->hasChildNodes())
-  {
-    g_log.error("XML file: " + fileName + "contains no root element.");
-    throw std::runtime_error("No root element in Facilities.xml file");
-  }
+    try
+    {
+      pDoc = pParser.parse(fileName);
+    } catch (...)
+    {
+      throw Kernel::Exception::FileError("Unable to parse file:", fileName);
+    }
+    // Get pointer to root element
+    Poco::XML::Element* pRootElem = pDoc->documentElement();
+    if (!pRootElem->hasChildNodes())
+    {
+      pDoc->release();
+      throw std::runtime_error("No root element in Facilities.xml file");
+    }
 
-  Poco::XML::NodeList* pNL_facility = pRootElem->getElementsByTagName("facility");
-  unsigned int n = pNL_facility->length();
+    Poco::XML::NodeList* pNL_facility = pRootElem->getElementsByTagName("facility");
+    unsigned int n = pNL_facility->length();
 
-  for (unsigned int i = 0; i < n; ++i)
-  {
-    Poco::XML::Element* elem = dynamic_cast<Poco::XML::Element*> (pNL_facility->item(i));
-    if (elem)
+    for (unsigned int i = 0; i < n; ++i)
+    {
+      Poco::XML::Element* elem = dynamic_cast<Poco::XML::Element*> (pNL_facility->item(i));
+      if (elem)
+      {
+        m_facilities.push_back(new FacilityInfo(elem));
+      }
+    }
+
+    if (m_facilities.empty())
     {
-      m_facilities.push_back(new FacilityInfo(elem));
+      pNL_facility->release();
+      pDoc->release();
+      throw std::runtime_error("The facility definition file " + fileName + " defines no facilities");
     }
+    
+    pNL_facility->release();
+    pDoc->release();
   }
-
-  if (m_facilities.empty())
+  catch(std::exception& e)
   {
-    throw std::runtime_error("The facility definition file " + fileName + " defines no facilities");
+    g_log.error(e.what());
   }
 
-  pNL_facility->release();
-  pDoc->release();
 }
 
 /** Get the default `
-- 
GitLab