diff options
| author | Petr Spacek <pspacek@redhat.com> | 2015-03-25 09:33:14 +0100 |
|---|---|---|
| committer | Petr Viktorin <pviktori@redhat.com> | 2015-05-21 14:25:12 +0200 |
| commit | 0ef4c7d10e0273219c8839f01ad9dc4d40d6c25b (patch) | |
| tree | 6495d57ff0fb5c80602afb8bdf4b241ee613c1da | |
| parent | d9abf6a4bd59bf579067518d4538a9140708ebdb (diff) | |
| download | dnspython-0ef4c7d10e0273219c8839f01ad9dc4d40d6c25b.tar.gz | |
Convert NoAnswer exception to the new DNSException style.
str() for paramerized exceptions returns string like:
The DNS response does not contain an answer to the question: localhost. IN URI
| -rw-r--r-- | dns/resolver.py | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/dns/resolver.py b/dns/resolver.py index 7e33d1b..bd4b0ec 100644 --- a/dns/resolver.py +++ b/dns/resolver.py @@ -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: |
