From: Bert Hubert Date: Thu, 17 Jul 2008 20:34:46 +0000 (+0000) Subject: improve error messages generated by the zoneparser-tng X-Git-Tag: rec-3.2~287 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d27ea3946ba22e0f6606010abf2357bfa6a277c7;p=thirdparty%2Fpdns.git improve error messages generated by the zoneparser-tng git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1235 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/zoneparser-tng.cc b/pdns/zoneparser-tng.cc index 49a1775954..582d8ab484 100644 --- a/pdns/zoneparser-tng.cc +++ b/pdns/zoneparser-tng.cc @@ -100,9 +100,7 @@ unsigned int ZoneParserTNG::makeTTLFromZone(const string& str) break; default: - throw ZoneParserTNG::exception("Unable to parse time specification '"+str+"' on line "+ - lexical_cast(d_filestates.top().d_lineno)+" of file '"+ - d_filestates.top().d_filename+"'"); + throw ZoneParserTNG::exception("Unable to parse time specification '"+str+"' "+getLineOfFile()); } return val; } @@ -218,7 +216,10 @@ bool findAndElide(string& line, char c) return false; } - +string ZoneParserTNG::getLineOfFile() +{ + return "on line "+lexical_cast(d_filestates.top().d_lineno)+" of file '"+d_filestates.top().d_filename+"'"; +} bool ZoneParserTNG::get(DNSResourceRecord& rr) { @@ -264,8 +265,7 @@ bool ZoneParserTNG::get(DNSResourceRecord& rr) goto retry; } else - throw exception("Can't parse zone line '"+d_line+"' on line "+lexical_cast(d_filestates.top().d_lineno)+ - " of file '"+d_filestates.top().d_filename); + throw exception("Can't parse zone line '"+d_line+"' "+getLineOfFile()); goto retry; } @@ -286,7 +286,7 @@ bool ZoneParserTNG::get(DNSResourceRecord& rr) d_prevqname=rr.qname; if(parts.empty()) - throw exception("Line with too little parts"); + throw exception("Line with too little parts "+getLineOfFile()); string nextpart; @@ -326,14 +326,13 @@ bool ZoneParserTNG::get(DNSResourceRecord& rr) continue; } catch(...) { - throw runtime_error("Parsing zone content on line "+ - lexical_cast(d_filestates.top().d_lineno)+ - " of file '"+d_filestates.top().d_filename+"': '"+nextpart+ + throw runtime_error("Parsing zone content "+getLineOfFile()+ + ": '"+nextpart+ "' doesn't look like a qtype, stopping loop"); } } if(!haveQTYPE) - throw exception("Malformed line "+lexical_cast(d_filestates.top().d_lineno)+" of '"+d_filestates.top().d_filename+"': "+d_line+"'"); + throw exception("Malformed line "+getLineOfFile()+": '"+d_line+"'"); rr.content=d_line.substr(range.first); diff --git a/pdns/zoneparser-tng.hh b/pdns/zoneparser-tng.hh index 2a5d1c4870..64487b2485 100644 --- a/pdns/zoneparser-tng.hh +++ b/pdns/zoneparser-tng.hh @@ -40,6 +40,7 @@ private: bool getTemplateLine(); void stackFile(const std::string& fname); unsigned makeTTLFromZone(const std::string& str); + string getLineOfFile(); string d_reldir; string d_line; string d_prevqname;