Commit ca4a11ca authored by Francis Dupont's avatar Francis Dupont

[5126] Improved SimpleParser getPosition

parent 0c35b770
......@@ -74,7 +74,7 @@ SimpleParser::getPosition(const std::string& name, const data::ConstElementPtr p
}
ConstElementPtr elem = parent->get(name);
if (!elem) {
return (data::Element::ZERO_POSITION());
return (parent->getPosition());
}
return (elem->getPosition());
}
......
......@@ -104,9 +104,9 @@ class SimpleParser {
/// @brief Utility method that returns position of an element
///
/// It's mostly useful for logging. When any necessary parameter is
/// missing (either parent is null or it doesn't contain specified
/// name) ZERO_POSITION is returned.
/// It's mostly useful for logging. If the element is missing
/// the parent position is returned or ZERO_POSITION if parent
/// is null.
///
/// @param name position of that element will be returned
/// @param parent parent element (optional)
......
......@@ -430,10 +430,7 @@ OptionDataParser::extractSpace(ConstElementPtr parent) const {
}
} catch (std::exception& ex) {
// Append position of the option space parameter. Note, that in the case
// when 'space' was not specified a default value will be used and we
// should never get here. Therefore, it is ok to call getPosition for
// the space parameter here as this parameter will always be specified.
// Append position of the option space parameter.
isc_throw(DhcpConfigError, ex.what() << " ("
<< getPosition("space", parent) << ")");
}
......@@ -1046,17 +1043,10 @@ SubnetConfigParser::createSubnet(ConstElementPtr params) {
try {
std::string hr_mode = getString(params, "reservation-mode");
subnet_->setHostReservationMode(hrModeFromText(hr_mode));
} catch (const BadValue& ex) {
ConstElementPtr mode = params->get("reservation-mode");
string pos;
if (mode) {
pos = mode->getPosition().str();
} else {
pos = params->getPosition().str();
}
isc_throw(DhcpConfigError, "Failed to process specified value "
} catch (const BadValue& ex) {
isc_throw(DhcpConfigError, "Failed to process specified value "
" of reservation-mode parameter: " << ex.what()
<< "(" << pos << ")");
<< "(" << getPosition("reservation-mode", params) << ")");
}
// Try setting up client class.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment