From: Carl Hetherington Date: Thu, 15 Nov 2018 21:57:07 +0000 (+0000) Subject: Use exceptions to report calls to Node with _node == 0. X-Git-Tag: v0.15.6~2 X-Git-Url: https://main.carlh.net/gitweb/?p=libcxml.git;a=commitdiff_plain;h=5532b044b33f40205c3fed2cd3d1c21dd718507b Use exceptions to report calls to Node with _node == 0. --- diff --git a/src/cxml.cc b/src/cxml.cc index 3c2eda2..d3ec9e7 100644 --- a/src/cxml.cc +++ b/src/cxml.cc @@ -43,7 +43,9 @@ cxml::Node::Node (xmlpp::Node* node) string cxml::Node::name () const { - assert (_node); + if (!_node) { + throw Error ("No node to read name from"); + } return _node->get_name (); } @@ -76,6 +78,9 @@ cxml::Node::optional_node_child (string name) const list > cxml::Node::node_children () const { + if (!_node) { + throw Error ("No node to read children from"); + } xmlpp::Node::NodeList c = _node->get_children (); list > n;