int64_t min, int64_t max) {
int64_t tmp = getInteger(scope, name);
if (tmp < min || tmp > max) {
- isc_throw(DhcpConfigError,
+ isc_throw(OutOfRange,
"The '" << name << "' value (" << tmp
<< ") is not within expected range: (" << min << " - " << max
- << ");");
+ << ")");
}
return (tmp);
}
/// @param max maximum allowed value
/// @return an integer value of the parameter
/// @throw DhcpConfigError if the parameter is not there or is not of
- /// appropriate type or is out of range
+ /// appropriate type.
+ /// @throw OutOfRange if the parameter is out of range
static int64_t getInteger(isc::data::ConstElementPtr scope,
const std::string& name,
int64_t min, int64_t max);
#include <cc/simple_parser.h>
#include <gtest/gtest.h>
+using namespace isc;
using namespace isc::data;
using namespace isc::asiolink;
using isc::dhcp::DhcpConfigError;
EXPECT_NO_THROW(x = SimpleParser::getInteger(json, "bar", 1, 100));
// Out of expected range. Should throw.
- EXPECT_THROW(x = SimpleParser::getInteger(json, "bar", 101, 200), DhcpConfigError);
- EXPECT_THROW(x = SimpleParser::getInteger(json, "bar", 1, 99), DhcpConfigError);
+ EXPECT_THROW(x = SimpleParser::getInteger(json, "bar", 101, 200), OutOfRange);
+ EXPECT_THROW(x = SimpleParser::getInteger(json, "bar", 1, 99), OutOfRange);
}
// This test exercises the getAndConvert template