Better error.
[libcxml.git] / src / cxml.cc
index 810abf81deae977c61ee11944382af10bff5eaf8..1d98529bdd0b08f49a08140355a085c79024eb94 100644 (file)
@@ -142,12 +142,12 @@ cxml::Node::string_attribute (string name) const
 {
        xmlpp::Element const * e = dynamic_cast<const xmlpp::Element *> (_node);
        if (!e) {
-               throw cxml::Error ("missing attribute");
+               throw cxml::Error ("missing attribute " + name);
        }
        
        xmlpp::Attribute* a = e->get_attribute (name);
        if (!a) {
-               throw cxml::Error ("missing attribute");
+               throw cxml::Error ("missing attribute " + name);
        }
 
        return a->get_value ();
@@ -253,7 +253,7 @@ void
 cxml::Document::read_file (filesystem::path file)
 {
        if (!filesystem::exists (file)) {
-               throw cxml::Error ("XML file does not exist");
+               throw cxml::Error ("XML file " + file.string() + " does not exist");
        }
        
        _parser->parse_file (file.string ());
@@ -284,7 +284,7 @@ cxml::Document::take_root_node ()
 
        _node = _parser->get_document()->get_root_node ();
        if (!_root_name.empty() && _node->get_name() != _root_name) {
-               throw cxml::Error ("unrecognised root node");
+               throw cxml::Error ("unrecognised root node " + _node->get_name() + "(expecting " + _root_name + ")");
        } else if (_root_name.empty ()) {
                _root_name = _node->get_name ();
        }