]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[4088] Exceptions added.
authorTomek Mrugalski <tomasz@isc.org>
Wed, 4 Nov 2015 15:43:56 +0000 (00:43 +0900)
committerTomek Mrugalski <tomasz@isc.org>
Wed, 4 Nov 2015 15:43:56 +0000 (00:43 +0900)
src/lib/eval/eval_context.cc
src/lib/eval/eval_context.h

index 812e41c58afd3e7c43081b4e3a456b80992409ec..86f90bda83c270c21de8b678dd9aa9cb14bdcf75 100644 (file)
@@ -61,11 +61,11 @@ EvalContext::parseString(const std::string& str)
 void
 EvalContext::error(const isc::eval::location& l, const std::string& m)
 {
-    std::cerr << l << ": " << m << std::endl;
+    isc_throw(EvalError, l << ": " << m);
 }
 
 void
 EvalContext::error (const std::string& m)
 {
-  std::cerr << m << std::endl;
+    isc_throw(EvalError, m);
 }
index 7c963f0af49d5872aaee6adfc2bf701fc3f9a1e5..a3dc95d9afe9cd60da1a1d82effc09c7e93a19fa 100644 (file)
@@ -17,6 +17,7 @@
 #include <string>
 #include <map>
 #include <eval/parser.h>
+#include <exceptions/exceptions.h>
 
 // Tell Flex the lexer's prototype ...
 #define YY_DECL isc::eval::EvalParser::symbol_type yylex (EvalContext& driver)
 // ... and declare it for the parser's sake.
 YY_DECL;
 
+/// @brief Evaluation error exception raised when trying to parse an axceptions.
+class EvalError : public isc::exceptions::Exception {
+public:
+    EvalError(const char* file, size_t line, const char* what) :
+        isc::Exception(file, line, what) { };
+};
+
+
 /// @brief Evaluation context, an interface to the expression evaluation.
 class EvalContext
 {