]> granicus.if.org Git - pdns/commitdiff
add error checking on server generation, improving the error message
authorbert hubert <bert.hubert@netherlabs.nl>
Wed, 1 Apr 2015 11:28:07 +0000 (13:28 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Wed, 1 Apr 2015 11:28:07 +0000 (13:28 +0200)
pdns/dnsdist-lua.cc

index b83f6e1db8e6d32bbe32f68aa575a7cc27e139f7..853d473792e91f11e266e6099c310cad38eb895a 100644 (file)
@@ -22,7 +22,15 @@ vector<std::function<void(void)>> setupLua(bool client, const std::string& confi
                          return std::make_shared<DownstreamState>(ComboAddress());
                        }
                        if(auto address = boost::get<string>(&pvars)) {
-                         auto ret=std::make_shared<DownstreamState>(ComboAddress(*address, 53));
+                         std::shared_ptr<DownstreamState> ret;
+                         try {
+                           ret=std::make_shared<DownstreamState>(ComboAddress(*address, 53));
+                         }
+                         catch(std::exception& e) {
+                           g_outputBuffer="Error creating new server: "+string(e.what());
+                           errlog("Error creating new server with address %s: %s", *address, e.what());
+                           return ret;
+                         }
 
                          if(qps) {
                            ret->qps=QPSLimiter(*qps, *qps);
@@ -47,7 +55,15 @@ vector<std::function<void(void)>> setupLua(bool client, const std::string& confi
                          return ret;
                        }
                        auto vars=boost::get<newserver_t>(pvars);
-                       auto ret=std::make_shared<DownstreamState>(ComboAddress(boost::get<string>(vars["address"]), 53));
+                       std::shared_ptr<DownstreamState> ret;
+                       try {
+                         ret=std::make_shared<DownstreamState>(ComboAddress(boost::get<string>(vars["address"]), 53));
+                       }
+                       catch(std::exception& e) {
+                         g_outputBuffer="Error creating new server: "+string(e.what());
+                         errlog("Error creating new server with address %s: %s", boost::get<string>(vars["address"]), e.what());
+                         return ret;
+                       }
                        
                        if(vars.count("qps")) {
                          int qps=boost::lexical_cast<int>(boost::get<string>(vars["qps"]));