Browse Source

[5019] SimpleParser methods are now public (used in global parsers)

Tomek Mrugalski 8 years ago
parent
commit
f3a880b0a6
2 changed files with 13 additions and 8 deletions
  1. 13 6
      src/lib/cc/simple_parser.cc
  2. 0 2
      src/lib/cc/simple_parser.h

+ 13 - 6
src/lib/cc/simple_parser.cc

@@ -19,10 +19,12 @@ std::string
 SimpleParser::getString(isc::data::ConstElementPtr scope, const std::string& name) {
     ConstElementPtr x = scope->get(name);
     if (!x) {
-        isc_throw(BadValue, "Element " << name << " not found");
+        isc_throw(BadValue, "String parameter " << name << " not found"
+                  << "(" << scope->getPosition() << ")");
     }
     if (x->getType() != Element::string) {
-        isc_throw(BadValue, "Element " << name << " found, but is not a string");
+        isc_throw(BadValue, "Element " << name << " found, but is not a string"
+                  << "(" << x->getPosition() << ")");
     }
 
     return (x->stringValue());
@@ -32,10 +34,12 @@ int64_t
 SimpleParser::getInteger(isc::data::ConstElementPtr scope, const std::string& name) {
     ConstElementPtr x = scope->get(name);
     if (!x) {
-        isc_throw(BadValue, "Element " << name << " not found");
+        isc_throw(BadValue, "Integer parameter " << name << " not found "
+                  << "(" << scope->getPosition() << ")");
     }
     if (x->getType() != Element::integer) {
-        isc_throw(BadValue, "Element " << name << " found, but is not an integer");
+        isc_throw(BadValue, "Element " << name << " found, but is not an integer"
+                  << "(" << x->getPosition() << ")");
     }
 
     return (x->intValue());
@@ -45,10 +49,13 @@ bool
 SimpleParser::getBoolean(isc::data::ConstElementPtr scope, const std::string& name) {
     ConstElementPtr x = scope->get(name);
     if (!x) {
-        isc_throw(BadValue, "Element " << name << " not found");
+        isc_throw(BadValue, "Boolean element " << name << " not found "
+                  << "(" << scope->getPosition() << ")");
+
     }
     if (x->getType() != Element::boolean) {
-        isc_throw(BadValue, "Element " << name << " found, but is not a boolean");
+        isc_throw(BadValue, "Element " << name << " found, but is not a boolean"
+                  << "(" << x->getPosition() << ")");
     }
 
     return (x->boolValue());

+ 0 - 2
src/lib/cc/simple_parser.h

@@ -113,8 +113,6 @@ class SimpleParser {
     static const data::Element::Position&
     getPosition(const std::string& name, const data::ConstElementPtr parent);
 
- protected:
-
     /// @brief Returns a string parameter from a scope
     ///
     /// Unconditionally returns a parameter. If the parameter is not there or