]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2428] Test and fix error handling in $INCLUDE
authorMichal 'vorner' Vaner <michal.vaner@nic.cz>
Tue, 11 Dec 2012 14:20:11 +0000 (15:20 +0100)
committerMichal 'vorner' Vaner <michal.vaner@nic.cz>
Tue, 11 Dec 2012 14:20:11 +0000 (15:20 +0100)
src/lib/dns/master_loader.cc
src/lib/dns/tests/master_loader_unittest.cc

index bf28ea29f5feeb59ebf32935c34d685ea19646ab..40710c29a752af7c685c3f221bcdefa17ed4a08f 100644 (file)
@@ -81,9 +81,7 @@ public:
         std::string error;
         if (!lexer_.pushSource(filename.c_str(), &error)) {
             if (initialized_) {
-                // $INCLUDE file
-                reportError(lexer_.getSourceName(), lexer_.getSourceLine(),
-                            error);
+                isc_throw(InternalException, error.c_str());
             } else {
                 // Top-level file
                 reportError("", 0, error);
@@ -116,7 +114,7 @@ public:
     void doInclude() {
         // First, get the filename to include
         const MasterToken::StringRegion
-            filename(lexer_.getNextToken(MasterLexer::QSTRING).
+            filename(lexer_.getNextToken(MasterToken::QSTRING).
                      getStringRegion());
 
         // TODO: Handle the case where there's Name after the
index 4860badee47e8052885bd75c5af75aefd17b1aa1..e79e2f8ca72e601be022d4620a362c5062cde3ba 100644 (file)
@@ -282,6 +282,10 @@ struct ErrorCase {
     // Check the unknown directive. The rest looks like ordinary RR,
     // so we see the $ is actually special.
     { "$UNKNOWN 3600    IN  A   192.0.2.1", "Unknown $ directive" },
+    { "$INCLUDE", "Missing include path" },
+    { "$INCLUDE /file/not/found", "Include file not found" },
+    { "$INCLUDE /file/not/found and here goes bunch of garbage",
+        "Include file not found and garbage at the end of line" },
     { NULL, NULL }
 };