diff --git a/src/Base/Reader.cpp b/src/Base/Reader.cpp index 60e15ecafb..dd7ad2d7f6 100644 --- a/src/Base/Reader.cpp +++ b/src/Base/Reader.cpp @@ -130,39 +130,45 @@ long Base::XMLReader::getAttributeAsInteger(const char* AttrName) const { AttrMapType::const_iterator pos = AttrMap.find(AttrName); - if (pos != AttrMap.end()) + if (pos != AttrMap.end()) { return atol(pos->second.c_str()); - else + } + else { // wrong name, use hasAttribute if not sure! - assert(0); - - return 0; + std::ostringstream msg; + msg << "XML Attribute: \"" << AttrName << "\" not found"; + throw Base::XMLAttributeError(msg.str()); + } } unsigned long Base::XMLReader::getAttributeAsUnsigned(const char* AttrName) const { AttrMapType::const_iterator pos = AttrMap.find(AttrName); - if (pos != AttrMap.end()) + if (pos != AttrMap.end()) { return strtoul(pos->second.c_str(),0,10); - else + } + else { // wrong name, use hasAttribute if not sure! - assert(0); - - return 0; + std::ostringstream msg; + msg << "XML Attribute: \"" << AttrName << "\" not found"; + throw Base::XMLAttributeError(msg.str()); + } } double Base::XMLReader::getAttributeAsFloat (const char* AttrName) const { AttrMapType::const_iterator pos = AttrMap.find(AttrName); - if (pos != AttrMap.end()) + if (pos != AttrMap.end()) { return atof(pos->second.c_str()); - else + } + else { // wrong name, use hasAttribute if not sure! - assert(0); - - return 0.0; + std::ostringstream msg; + msg << "XML Attribute: \"" << AttrName << "\" not found"; + throw Base::XMLAttributeError(msg.str()); + } } const char* Base::XMLReader::getAttribute (const char* AttrName) const