The YAML code already disallows an empty forwarders list. The added
case mainly covers the case when an old-style forward file is parsed
as if it's YAML. This now generated an error:
Feb 21 09:57:39 msg="Fatal error" error="empty list of forwarders for domain '- zone: example.com\"on line 1 of tmp/f.conf" subsystem="config" level="0" prio="Critical" tid="0" ts="
1740128259.137" exception="PDNSException"
This hopefully makes admins realize rec is trying to parse YAML
content, but is expecting old-style as the file does not end in
in .yml.
''',
'doc-new' : '''
Same as :ref:`setting-forward-zones`, parsed from a file as a sequence of `Forward Zone`_.
+ The filename MUST end in ``.yml`` for the content to be parsed as YAML.
.. code-block:: yaml
{
vector<string> servers;
stringtok(servers, input, sepa);
+ if (servers.empty()) {
+ throw PDNSException("empty list of forwarders for domain '" + zone + '"');
+ }
authDomain.d_servers.clear();
vector<string> addresses;
try {
convertServersForAD(domain, instructions, authDomain, ",; ", log, false);
}
+ catch (const PDNSException& e) {
+ throw PDNSException(e.reason + "on line " + std::to_string(linenum) + " of " + filename);
+ }
catch (...) {
throw PDNSException("Conversion error parsing line " + std::to_string(linenum) + " of " + filename);
}