]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Exception doc
authorBob Halley <halley@dnspython.org>
Mon, 2 Jan 2017 15:47:20 +0000 (07:47 -0800)
committerBob Halley <halley@dnspython.org>
Mon, 2 Jan 2017 15:47:20 +0000 (07:47 -0800)
dns/exception.py
doc/exceptions.rst [new file with mode: 0644]
doc/manual.rst

index 0e468c75a019798b434a46de974f51af06db75fa..89aee9c76c3da0e5487f82f8e77b52da155971f9 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
+# Copyright (C) 2003-2017 Nominum, Inc.
 #
 # Permission to use, copy, modify, and distribute this software and its
 # documentation for any purpose with or without fee is hereby granted,
 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
 # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-"""Common DNS Exceptions."""
+"""Common DNS Exceptions.
 
+Dnspython modules may also define their own exceptions, which will
+always be subclasses of ``DNSException``.
+"""
 
 class DNSException(Exception):
-
     """Abstract base class shared by all dnspython exceptions.
 
     It supports two basic modes of operation:
 
-    a) Old/compatible mode is used if __init__ was called with
-    empty \**kwargs.
-    In compatible mode all \*args are passed to standard Python Exception class
-    as before and all \*args are printed by standard __str__ implementation.
-    Class variable msg (or doc string if msg is None) is returned from str()
-    if \*args is empty.
-
-    b) New/parametrized mode is used if __init__ was called with
-    non-empty \**kwargs.
-    In the new mode \*args has to be empty and all kwargs has to exactly match
-    set in class variable self.supp_kwargs. All kwargs are stored inside
-    self.kwargs and used in new __str__ implementation to construct
-    formatted message based on self.fmt string.
-
-    In the simplest case it is enough to override supp_kwargs and fmt
-    class variables to get nice parametrized messages.
+    a) Old/compatible mode is used if ``__init__`` was called with
+    empty *kwargs*.  In compatible mode all *args* are passed
+    to the standard Python Exception class as before and all *args* are
+    printed by the standard ``__str__`` implementation.  Class variable
+    ``msg`` (or doc string if ``msg`` is ``None``) is returned from ``str()``
+    if *args* is empty.
+
+    b) New/parametrized mode is used if ``__init__`` was called with
+    non-empty *kwargs*.
+    In the new mode *args* must be empty and all kwargs must match
+    those set in class variable ``supp_kwargs``. All kwargs are stored inside
+    ``self.kwargs`` and used in a new ``__str__`` implementation to construct
+    a formatted message based on the ``fmt`` class variable, a ``string``.
+
+    In the simplest case it is enough to override the ``supp_kwargs``
+    and ``fmt`` class variables to get nice parametrized messages.
     """
+
     msg = None  # non-parametrized message
     supp_kwargs = set()  # accepted parameters for _fmt_kwargs (sanity check)
     fmt = None  # message parametrized with results from _fmt_kwargs
@@ -102,27 +105,22 @@ class DNSException(Exception):
 
 
 class FormError(DNSException):
-
     """DNS message is malformed."""
 
 
 class SyntaxError(DNSException):
-
     """Text input is malformed."""
 
 
 class UnexpectedEnd(SyntaxError):
-
     """Text input ended unexpectedly."""
 
 
 class TooBig(DNSException):
-
     """The DNS message is too big."""
 
 
 class Timeout(DNSException):
-
     """The DNS operation timed out."""
     supp_kwargs = set(['timeout'])
     fmt = "The DNS operation timed out after {timeout} seconds"
diff --git a/doc/exceptions.rst b/doc/exceptions.rst
new file mode 100644 (file)
index 0000000..0fc9e86
--- /dev/null
@@ -0,0 +1,7 @@
+.. _exceptions:
+
+Common Exceptions
+=================
+
+.. automodule:: dns.exception
+   :members:
index 50b1afb33c26675b18670a23dfd29b76f972d966..b3e18b076410a564199cfe0cdc961238c969c2f7 100644 (file)
@@ -8,3 +8,4 @@ Dnspython Manual
    py2vs3
    name
    rdata
+   exceptions