Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve dnsdist error message on a common typo/config mistake #4632

Merged
merged 1 commit into from
Nov 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions pdns/dnsdist-console.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down