Commit 08d650e4 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[64-client-class-cmds-hook] Control whether class def parser appends position.

parent 9cf2af27
......@@ -19,6 +19,7 @@
#include <boost/foreach.hpp>
#include <algorithm>
#include <sstream>
using namespace isc::data;
using namespace isc::asiolink;
......@@ -68,7 +69,8 @@ ExpressionParser::parse(ExpressionPtr& expression,
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()) {
......@@ -207,8 +209,13 @@ ClientClassDefParser::parse(ClientClassDictionaryPtr& class_dictionary,
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());
}
}
......
......@@ -90,10 +90,16 @@ public:
/// @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
......
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