simplify dns exception catching

This commit is contained in:
KiekerJan 2022-10-23 23:40:04 +02:00
parent c462008a5e
commit 8d8d6e158b
1 changed files with 3 additions and 7 deletions

View File

@ -1036,15 +1036,11 @@ def set_secondary_dns(hostnames, env):
# Resolve hostname.
try:
response = resolver.resolve(item, "A")
except (dns.resolver.NoNameservers, dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
except (dns.resolver.NoNameservers, dns.resolver.NXDOMAIN, dns.resolver.NoAnswer, dns.resolver.Timeout):
try:
response = resolver.resolve(item, "AAAA")
except (dns.resolver.NoNameservers, dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
raise ValueError("Could not resolve the IP address of %s due to dns error." % item)
except (dns.resolver.Timeout):
raise ValueError("Could not resolve the IP address of %s due to timeout." % item)
except (dns.resolver.Timeout):
raise ValueError("Could not resolve the IP address of %s due to timeout." % item)
except (dns.resolver.NoNameservers, dns.resolver.NXDOMAIN, dns.resolver.NoAnswer, dns.resolver.Timeout):
raise ValueError("Could not resolve the IP address of %s." % item)
else:
# Validate IP address.
try: