From 8d8d6e158b18a5653a4d3cd062812626f77b0940 Mon Sep 17 00:00:00 2001 From: KiekerJan Date: Sun, 23 Oct 2022 23:40:04 +0200 Subject: [PATCH] simplify dns exception catching --- management/dns_update.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/management/dns_update.py b/management/dns_update.py index 3c761ac8..9256c0ff 100755 --- a/management/dns_update.py +++ b/management/dns_update.py @@ -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: