Catch temporary problems with resolving DNS entries.
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 4 Aug 2014 14:53:54 +0000 (14:53 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 4 Aug 2014 14:53:54 +0000 (14:53 +0000)
src/ddns/errors.py
src/ddns/system.py

index fac3890..58928f3 100644 (file)
@@ -117,6 +117,14 @@ class DDNSRequestError(DDNSError):
        reason = N_("Request error")
 
 
+class DDNSResolveError(DDNSNetworkError):
+       """
+               Thrown when a DNS record could not be resolved
+               because of a local error.
+       """
+       reason = N_("Could not resolve DNS entry")
+
+
 class DDNSServiceUnavailableError(DDNSNetworkError):
        """
                Equivalent to HTTP error code 503.
index 6b76333..79bf192 100644 (file)
@@ -193,6 +193,10 @@ class DDNSSystem(object):
 
                except urllib2.URLError, e:
                        if e.reason:
+                               # Name or service not known
+                               if e.reason.errno == -2:
+                                       raise DDNSResolveError
+
                                # Network Unreachable (e.g. no IPv6 access)
                                if e.reason.errno == 101:
                                        raise DDNSNetworkUnreachableError
@@ -321,6 +325,10 @@ class DDNSSystem(object):
                        if e.errno == -2:
                                return []
 
+                       # Temporary failure in name resolution
+                       elif e.errno == -3:
+                               raise DDNSResolveError(hostname)
+
                        # No record for requested family available (e.g. no AAAA)
                        elif e.errno == -5:
                                return []