From 694d84857af02588b1effb9ddf51c6847ff2a9ae Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 4 Aug 2014 14:53:54 +0000 Subject: [PATCH] Catch temporary problems with resolving DNS entries. --- src/ddns/errors.py | 8 ++++++++ src/ddns/system.py | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/ddns/errors.py b/src/ddns/errors.py index fac3890..58928f3 100644 --- a/src/ddns/errors.py +++ b/src/ddns/errors.py @@ -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. diff --git a/src/ddns/system.py b/src/ddns/system.py index 6b76333..79bf192 100644 --- a/src/ddns/system.py +++ b/src/ddns/system.py @@ -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 [] -- 2.39.2