From: Petr Spacek Date: Thu, 15 Jan 2015 16:25:10 +0000 (+0100) Subject: Support string representation for all DNSExceptions. X-Git-Tag: v1.13.0~35^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4bdb7113dba8ed819d8454a1e8f2916ee33d9a6;p=thirdparty%2Fdnspython.git Support string representation for all DNSExceptions. Doc string is used in cases where more specific message was not provided during instantiation/raise. --- diff --git a/dns/exception.py b/dns/exception.py index db6ef6e6..575cebe8 100644 --- a/dns/exception.py +++ b/dns/exception.py @@ -17,7 +17,12 @@ class DNSException(Exception): """Abstract base class shared by all dnspython exceptions.""" - pass + def __init__(self, *args): + if args: + super(DNSException, self).__init__(*args) + else: + # doc string is better implicit message than empty string + super(DNSException, self).__init__(self.__doc__) class FormError(DNSException): """DNS message is malformed."""