mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 21:45:37 +00:00
[4094] Changed EvalNotBoolError to shared EvalTypeError
This commit is contained in:
@@ -32,7 +32,7 @@ bool evaluate(const Expression& expr, const Pkt& pkt) {
|
||||
} else if (values.top() == "true") {
|
||||
return (true);
|
||||
} else {
|
||||
isc_throw(EvalNotBoolError, "Incorrect evaluation type. Expected "
|
||||
isc_throw(EvalTypeError, "Incorrect evaluation type. Expected "
|
||||
"\"false\" or \"true\", got \"" << values.top() << "\"");
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ namespace dhcp {
|
||||
/// @return the boolean decision
|
||||
/// @throw EvalStackError if there is not exactly one element on the value
|
||||
/// stack at the end of the evaluation
|
||||
/// @throw EvalNotBoolError if the value at the top of the stack at the
|
||||
/// @throw EvalTypeError if the value at the top of the stack at the
|
||||
/// end of the evaluation is not "false" or "true"
|
||||
bool evaluate(const Expression& expr, const Pkt& pkt);
|
||||
|
||||
|
@@ -124,7 +124,7 @@ TEST_F(EvaluateTest, bad4) {
|
||||
TokenPtr bad;
|
||||
ASSERT_NO_THROW(bad.reset(new TokenString("bad")));
|
||||
e_.push_back(bad);
|
||||
ASSERT_THROW(evaluate(e_, *pkt4_), EvalNotBoolError);
|
||||
ASSERT_THROW(evaluate(e_, *pkt4_), EvalTypeError);
|
||||
}
|
||||
|
||||
// This checks the evaluation must lead to "false" or "true"
|
||||
@@ -133,7 +133,7 @@ TEST_F(EvaluateTest, bad6) {
|
||||
TokenPtr bad;
|
||||
ASSERT_NO_THROW(bad.reset(new TokenString("bad")));
|
||||
e_.push_back(bad);
|
||||
ASSERT_THROW(evaluate(e_, *pkt6_), EvalNotBoolError);
|
||||
ASSERT_THROW(evaluate(e_, *pkt6_), EvalTypeError);
|
||||
}
|
||||
|
||||
// This checks the evaluation must leave only one value on the stack
|
||||
|
@@ -46,11 +46,11 @@ public:
|
||||
isc::Exception(file, line, what) { };
|
||||
};
|
||||
|
||||
/// @brief EvalNotBoolError is thrown when a boolean (i.e., "false" or
|
||||
/// "true") was required but is not.
|
||||
class EvalNotBoolError : public Exception {
|
||||
/// @brief EvalTypeError is thrown when a value on the stack has a content
|
||||
/// with an unexpected type.
|
||||
class EvalTypeError : public Exception {
|
||||
public:
|
||||
EvalNotBoolError(const char* file, size_t line, const char* what) :
|
||||
EvalTypeError(const char* file, size_t line, const char* what) :
|
||||
isc::Exception(file, line, what) { };
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user