From: Miod Vallat Date: Thu, 20 Mar 2025 15:03:59 +0000 (+0100) Subject: Try and be more helpful in YAML error exceptions. X-Git-Tag: dnsdist-2.0.0-alpha2~120^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F15334%2Fhead;p=thirdparty%2Fpdns.git Try and be more helpful in YAML error exceptions. --- diff --git a/modules/geoipbackend/geoipbackend.cc b/modules/geoipbackend/geoipbackend.cc index e0219de149..f8781e2811 100644 --- a/modules/geoipbackend/geoipbackend.cc +++ b/modules/geoipbackend/geoipbackend.cc @@ -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); } }