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