Better error message for unfound new slave domains #3051

Merged
merged 1 commit into from Jul 6, 2016

Projects

None yet

7 participants

@pieterlexis
Member

Closes #2405

@Habbie Habbie commented on an outdated diff Dec 21, 2015
modules/bindbackend/bindbackend2.cc
@@ -818,7 +820,10 @@ void Bind2Backend::loadConfig(string* status)
}
catch(std::exception &ae) {
ostringstream msg;
- msg<<" error at "+nowTime()+" parsing '"<<i->name.toString()<<"' from file '"<<i->filename<<"': "<<ae.what();
+ if (strcmp(ae.what(), "No such file or directory") && isNew && i->type == "slave")
@Habbie
Habbie Dec 21, 2015 Member

That strcmp smells bad :)

@cmouse
Contributor
cmouse commented Dec 21, 2015

My eyes :(

@Habbie Habbie added this to the auth-4-alpha1 milestone Dec 22, 2015
@pieterlexis
Member

Could use another review

@cmouse
Contributor
cmouse commented Jan 12, 2016

LGTM. 👍

@zeha
Collaborator
zeha commented Jan 12, 2016

Doing the errno check that late is probably unsafe/unportable.

@cmouse
Contributor
cmouse commented Jan 12, 2016

Could you catch http://en.cppreference.com/w/cpp/io/ios_base/failure instead? It comes with error code. Or std::system_error, has code as well.

@pieterlexis
Member

The zoneparser now throws a std::system_error and as that is a subclass of std::exception all other catches still work.

@Habbie
Member
Habbie commented Feb 4, 2016
zoneparser-tng.cc: In member function ‘void ZoneParserTNG::stackFile(const string&)’:
zoneparser-tng.cc:59:5: error: ‘error_code’ is not a member of ‘std’
     std::error_code ec (errno,std::generic_category());
     ^
zoneparser-tng.cc:59:21: error: expected ‘;’ before ‘ec’
     std::error_code ec (errno,std::generic_category());
                     ^
zoneparser-tng.cc:60:11: error: ‘system_error’ is not a member of ‘std’
     throw std::system_error(ec, "Unable to open file '"+fname+"': "+stringerror());
           ^
zoneparser-tng.cc:60:29: error: ‘ec’ was not declared in this scope
     throw std::system_error(ec, "Unable to open file '"+fname+"': "+stringerror());
                             ^
make[3]: *** [zoneparser-tng.o] Error 1
@pieterlexis
Member

std::errorcode is c++2011, interesting that it fails on travis

@Habbie
Member
Habbie commented Feb 16, 2016

LGTM (pending figuring out why Travis is throwing a fit)

@nlyan
Contributor
nlyan commented Feb 16, 2016

Can't help with the build issue on travis, but I'd recommend deploying a function like this somewhere to avoid code bloat with system_error

namespace  { // or mark it static
template <typename Message> __attribute__ ((noinline, cold, noreturn)) 
void throw_errno (Message&& msg) {
    throw std::system_error (errno, std::system_category(), 
              std::forward<Message> (msg));
}
}

You can see what kind of codegen you get without it, even at -O2, here: http://goo.gl/Kzfcsw

@Habbie Habbie modified the milestone: auth-4.0.0, auth-4-alpha3 Apr 12, 2016
@mind04
Contributor
mind04 commented Jul 4, 2016

Please note the small warning sign on the cplusplus.com page:

This page describes a feature introduced by the latest revision of the C++ standard (2011). Older compilers may not support it.
@rgacogne
Member
rgacogne commented Jul 4, 2016

It seems to work by adding #include <system_error> to both modified files.

@cmouse cmouse and 1 other commented on an outdated diff Jul 4, 2016
modules/bindbackend/bindbackend2.cc
ostringstream msg;
- msg<<" error at "+nowTime()+" parsing '"<<i->name.toString()<<"' from file '"<<i->filename<<"': "<<ae.what();
+ if (ae.code().value() == ENOENT && isNew && i->type == "slave")
+ msg<<" error at "+nowTime()<<" no file found for new slave domain '"<<i->name.toString()<<"'. Has not been AXFR'd yet";
@cmouse
cmouse Jul 4, 2016 Contributor

Didn't the logger support printing DNSName w/o toString today?

@pieterlexis
pieterlexis Jul 4, 2016 Member

when #4062 is merged, ostreams support this properly

@pieterlexis pieterlexis merged commit 523d7bf into PowerDNS:master Jul 6, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@pieterlexis pieterlexis deleted the pieterlexis:issue-2405-misleading-error-in-bind branch Jul 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment