]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Try and be more helpful in YAML error exceptions. 15334/head
authorMiod Vallat <miod.vallat@powerdns.com>
Thu, 20 Mar 2025 15:03:59 +0000 (16:03 +0100)
committerMiod Vallat <miod.vallat@powerdns.com>
Thu, 20 Mar 2025 15:03:59 +0000 (16:03 +0100)
modules/geoipbackend/geoipbackend.cc

index e0219de1490da02643fb629e0fd4d570acf97b66..f8781e28110f4ae0a53be640e4128be477fc7a57 100644 (file)
@@ -392,12 +392,20 @@ void GeoIPBackend::initialize()
     g_log << Logger::Warning << "No GeoIP database files loaded!" << endl;
   }
 
-  if (!getArg("zones-file").empty()) {
+  std::string zonesFile{getArg("zones-file")};
+  if (!zonesFile.empty()) {
     try {
-      config = YAML::LoadFile(getArg("zones-file"));
+      config = YAML::LoadFile(zonesFile);
     }
     catch (YAML::Exception& ex) {
-      throw PDNSException(string("Cannot read config file ") + ex.msg);
+      std::string description{};
+      if (!ex.mark.is_null()) {
+        description = "Configuration error in " + zonesFile + ", line " + std::to_string(ex.mark.line + 1) + ", column " + std::to_string(ex.mark.column + 1);
+      }
+      else {
+        description = "Cannot read config file " + zonesFile;
+      }
+      throw PDNSException(description + ": " + ex.msg);
     }
   }