Browse Source

[4094] Changed EvalNotBoolError to shared EvalTypeError

Francis Dupont 9 years ago
parent
commit
8197502648

+ 1 - 1
src/lib/eval/evaluate.cc

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

+ 1 - 1
src/lib/eval/evaluate.h

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

+ 2 - 2
src/lib/eval/tests/evaluate_unittest.cc

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

+ 4 - 4
src/lib/eval/token.h

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