From cbbd15333c7a2ccde6e825dd423042fe7e142fd4 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Wed, 1 Apr 2015 13:28:07 +0200 Subject: [PATCH] add error checking on server generation, improving the error message --- pdns/dnsdist-lua.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index b83f6e1db8..853d473792 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -22,7 +22,15 @@ vector> setupLua(bool client, const std::string& confi return std::make_shared(ComboAddress()); } if(auto address = boost::get(&pvars)) { - auto ret=std::make_shared(ComboAddress(*address, 53)); + std::shared_ptr ret; + try { + ret=std::make_shared(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> setupLua(bool client, const std::string& confi return ret; } auto vars=boost::get(pvars); - auto ret=std::make_shared(ComboAddress(boost::get(vars["address"]), 53)); + std::shared_ptr ret; + try { + ret=std::make_shared(ComboAddress(boost::get(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(vars["address"]), e.what()); + return ret; + } if(vars.count("qps")) { int qps=boost::lexical_cast(boost::get(vars["qps"])); -- 2.47.2