]> granicus.if.org Git - pdns/commitdiff
with this commit we pretty up an otherwise bloody useless error on typing: newServer...
authorbert hubert <bert.hubert@netherlabs.nl>
Tue, 25 Oct 2016 20:45:04 +0000 (22:45 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Tue, 25 Oct 2016 20:45:04 +0000 (22:45 +0200)
The cause of the error is deep in the bowels of Lua and/or LuaWrapper. Even if we caught/fixed this error in a more karmic place, we'd still want to output
this error message. Also, dragons live there.

pdns/dnsdist-console.cc

index 1306bb803378101f768b22f2e875bda3e5b4ea60..56bd5fb0c9525a8b5ef572f4bed375282624d207 100644 (file)
@@ -186,7 +186,6 @@ void doConsole()
               >
             >
           >(withReturn ? ("return "+line) : line);
-        
         if(ret) {
           if (const auto strValue = boost::get<shared_ptr<DownstreamState>>(&*ret)) {
             cout<<(*strValue)->getName()<<endl;
@@ -221,9 +220,13 @@ void doConsole()
       // tried to return something we don't understand
     }
     catch(const LuaContext::ExecutionErrorException& e) {
-      std::cerr << e.what(); 
+      if(!strcmp(e.what(),"invalid key to 'next'"))
+        std::cerr<<"Error parsing parameters, did you forget parameter name?";
+      else
+        std::cerr << e.what(); 
       try {
         std::rethrow_if_nested(e);
+
         std::cerr << std::endl;
       } catch(const std::exception& e) {
         // e is the exception that was thrown from inside the lambda
@@ -488,16 +491,19 @@ try
       // tried to return something we don't understand
     }
     catch(const LuaContext::ExecutionErrorException& e) {
-      response = "Error: " + string(e.what()) + ": ";
+      if(!strcmp(e.what(),"invalid key to 'next'"))
+        response = "Error: Parsing function parameters, did you forget parameter name?";
+      else
+        response = "Error: " + string(e.what());
       try {
         std::rethrow_if_nested(e);
       } catch(const std::exception& e) {
         // e is the exception that was thrown from inside the lambda
-        response+= string(e.what());
+        response+= ": " + string(e.what());
       }
       catch(const PDNSException& e) {
         // e is the exception that was thrown from inside the lambda
-        response += string(e.reason);
+        response += ": " + string(e.reason);
       }
     }
     catch(const LuaContext::SyntaxErrorException& e) {