From 161da30c52145504aaddd03dd500359e60843b07 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Tue, 18 May 2010 19:16:15 +0200 Subject: [PATCH] feature #212: Catch exception when initializing a VM object --- src/scheduler/src/pool/VirtualMachinePoolXML.cc | 15 +++++++++++++-- src/scheduler/src/xml/ObjectXML.cc | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/scheduler/src/pool/VirtualMachinePoolXML.cc b/src/scheduler/src/pool/VirtualMachinePoolXML.cc index 102f1fe2c3..93667fd186 100644 --- a/src/scheduler/src/pool/VirtualMachinePoolXML.cc +++ b/src/scheduler/src/pool/VirtualMachinePoolXML.cc @@ -15,6 +15,7 @@ /* -------------------------------------------------------------------------- */ #include "VirtualMachinePoolXML.h" +#include int VirtualMachinePoolXML::set_up() { @@ -88,9 +89,19 @@ void VirtualMachinePoolXML::add_object(xmlNodePtr node) } else { - VirtualMachineXML* vm = new VirtualMachineXML( message ); + try + { + VirtualMachineXML* vm = new VirtualMachineXML( message ); - objects.insert( pair(vid, vm) ); + objects.insert( pair(vid, vm) ); + } + catch(runtime_error& re) + { + ostringstream oss_re; + + oss_re << re.what(); + NebulaLog::log("VM",Log::ERROR,oss_re); + } } } diff --git a/src/scheduler/src/xml/ObjectXML.cc b/src/scheduler/src/xml/ObjectXML.cc index 61b9882053..f67df49f91 100644 --- a/src/scheduler/src/xml/ObjectXML.cc +++ b/src/scheduler/src/xml/ObjectXML.cc @@ -202,7 +202,7 @@ void ObjectXML::xml_parse(const string &xml_doc) if (xml == 0) { - throw("Error parsing XML Document"); + throw runtime_error("Error parsing XML Document"); } ctx = xmlXPathNewContext(xml); @@ -210,7 +210,7 @@ void ObjectXML::xml_parse(const string &xml_doc) if (ctx == 0) { xmlFreeDoc(xml); - throw("Unable to create new XPath context"); + throw runtime_error("Unable to create new XPath context"); } }