#include <boost/foreach.hpp>
#include <algorithm>
+#include <sstream>
using namespace isc::data;
using namespace isc::asiolink;
void
ClientClassDefParser::parse(ClientClassDictionaryPtr& class_dictionary,
ConstElementPtr class_def_cfg,
- uint16_t family) {
+ uint16_t family,
+ bool append_error_position) {
// name is now mandatory
std::string name = getString(class_def_cfg, "name");
if (name.empty()) {
depend_on_known, options, defs,
user_context, next_server, sname, filename);
} catch (const std::exception& ex) {
- isc_throw(DhcpConfigError, "Can't add class: " << ex.what()
- << " (" << class_def_cfg->getPosition() << ")");
+ std::ostringstream s;
+ s << "Can't add class: " << ex.what();
+ // Append position of the error in JSON string if required.
+ if (append_error_position) {
+ s << " (" << class_def_cfg->getPosition() << ")";
+ }
+ isc_throw(DhcpConfigError, s.str());
}
}
/// @param class_dictionary dictionary into which the class should be added
/// @param client_class_def a configuration entry to be parsed.
/// @param family the address family of the client class.
+ /// @param append_error_position Boolean flag indicating if position
+ /// of the parsed string within parsed JSON should be appended. The
+ /// default setting is to append it, but it is typically set to false
+ /// when this parser is used by hooks libraries.
///
/// @throw DhcpConfigError if parsing was unsuccessful.
void parse(ClientClassDictionaryPtr& class_dictionary,
- isc::data::ConstElementPtr client_class_def, uint16_t family);
+ isc::data::ConstElementPtr client_class_def,
+ uint16_t family,
+ bool append_error_position = true);
};
/// @brief Defines a pointer to a ClientClassDefParser