From ffcb96e044805228e4415115b938767d68916d85 Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Thu, 20 Mar 2025 16:03:59 +0100 Subject: [PATCH] Try and be more helpful in YAML error exceptions. --- modules/geoipbackend/geoipbackend.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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); } } -- 2.47.2