]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Convert NoAnswer exception to the new DNSException style.
authorPetr Spacek <pspacek@redhat.com>
Wed, 25 Mar 2015 08:33:14 +0000 (09:33 +0100)
committerPetr Viktorin <pviktori@redhat.com>
Thu, 21 May 2015 12:25:12 +0000 (14:25 +0200)
str() for paramerized exceptions returns string like:
The DNS response does not contain an answer to the question: localhost. IN URI

dns/resolver.py

index 7e33d1b41c8a5e9ecb8a3b1643c631e70301f056..bd4b0ec3a26a94be1560e6f70cba6b819c6b866d 100644 (file)
@@ -73,19 +73,11 @@ class YXDOMAIN(dns.exception.DNSException):
 
 Timeout = dns.exception.Timeout
 
+
 class NoAnswer(dns.exception.DNSException):
     """The DNS response does not contain an answer to the question."""
-    def __init__(self, question=None):
-        super(dns.exception.DNSException, self).__init__()
-        self.question = question
-
-    def __str__(self):
-        message = self.__doc__
-        if self.question:
-            message = message[0:-1]
-            for q in self.question:
-                message += ' %s' % q
-        return message
+    fmt = '%s: {question}' % __doc__[:-1]
+    supp_kwargs = set(['question'])
 
 
 class NoNameservers(dns.exception.DNSException):
@@ -181,7 +173,7 @@ class Answer(object):
                 if raise_on_no_answer:
                     raise NoAnswer(question=response.question)
         if rrset is None and raise_on_no_answer:
-            raise NoAnswer(question=response.question)
+            raise NoAnswer(question=request.question)
         self.canonical_name = qname
         self.rrset = rrset
         if rrset is None: