/// @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)
}
} 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) << ")");
}
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.