2
0
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:
Francis Dupont
2015-11-13 23:21:13 +01:00
parent e15edffe3e
commit 8197502648
4 changed files with 8 additions and 8 deletions

View File

@@ -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() << "\"");
}
}

View File

@@ -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);

View File

@@ -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

View File

@@ -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) { };
};