]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
improve error messages generated by the zoneparser-tng
authorBert Hubert <bert.hubert@netherlabs.nl>
Thu, 17 Jul 2008 20:34:46 +0000 (20:34 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Thu, 17 Jul 2008 20:34:46 +0000 (20:34 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1235 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/zoneparser-tng.cc
pdns/zoneparser-tng.hh

index 49a1775954aa6e76bd000c01292e0d11c01ea4a5..582d8ab484c0b4520b6f0787eaacbbdac7516002 100644 (file)
@@ -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<string>(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<string>(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<string>(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<string>(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<string>(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);
 
index 2a5d1c4870cad713c7f8793dfc849bb7f1854016..64487b2485255bdcfbe79c64b106ae088c51e214 100644 (file)
@@ -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;