Skip to content
Snippets Groups Projects
Commit 94550d97 authored by Roman Tolchenov's avatar Roman Tolchenov
Browse files

Fixed the particular issue of python crashing, but it is not clear for me why...

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
parent 3bc0a718
No related branches found
No related tags found
No related merge requests found
...@@ -920,41 +920,51 @@ void ConfigServiceImpl::updateFacilities(const std::string& fName) ...@@ -920,41 +920,51 @@ void ConfigServiceImpl::updateFacilities(const std::string& fName)
// Set up the DOM parser and parse xml file // Set up the DOM parser and parse xml file
Poco::XML::DOMParser pParser; Poco::XML::DOMParser pParser;
Poco::XML::Document* pDoc; Poco::XML::Document* pDoc;
try try
{ {
pDoc = pParser.parse(fileName); try
} catch (...) {
{ pDoc = pParser.parse(fileName);
g_log.error("Unable to parse file " + fileName); } catch (...)
throw Kernel::Exception::FileError("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(); // Get pointer to root element
if (!pRootElem->hasChildNodes()) 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"); pDoc->release();
} throw std::runtime_error("No root element in Facilities.xml file");
}
Poco::XML::NodeList* pNL_facility = pRootElem->getElementsByTagName("facility"); Poco::XML::NodeList* pNL_facility = pRootElem->getElementsByTagName("facility");
unsigned int n = pNL_facility->length(); unsigned int n = pNL_facility->length();
for (unsigned int i = 0; i < n; ++i) for (unsigned int i = 0; i < n; ++i)
{ {
Poco::XML::Element* elem = dynamic_cast<Poco::XML::Element*> (pNL_facility->item(i)); Poco::XML::Element* elem = dynamic_cast<Poco::XML::Element*> (pNL_facility->item(i));
if (elem) 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();
} }
catch(std::exception& e)
if (m_facilities.empty())
{ {
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 ` /** Get the default `
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment