Exceptions

Common Exceptions

Common DNS Exceptions.

Dnspython modules may also define their own exceptions, which will always be subclasses of DNSException.

exception dns.exception.DNSException(*args, **kwargs)[source]

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 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.

exception dns.exception.FormError(*args, **kwargs)[source]

DNS message is malformed.

exception dns.exception.SyntaxError(*args, **kwargs)[source]

Text input is malformed.

exception dns.exception.Timeout(*args, **kwargs)[source]

The DNS operation timed out.

exception dns.exception.TooBig(*args, **kwargs)[source]

The DNS message is too big.

exception dns.exception.UnexpectedEnd(*args, **kwargs)[source]

Text input ended unexpectedly.

dns.dnssec Exceptions

exception dns.dnssec.UnsupportedAlgorithm(*args, **kwargs)[source]

The DNSSEC algorithm is not supported.

exception dns.dnssec.ValidationFailure(*args, **kwargs)[source]

The DNSSEC signature is invalid.

dns.message Exceptions

exception dns.message.BadEDNS(*args, **kwargs)[source]

An OPT record occurred somewhere other than the additional data section.

exception dns.message.BadTSIG(*args, **kwargs)[source]

A TSIG record occurred somewhere other than the end of the additional data section.

exception dns.message.ShortHeader(*args, **kwargs)[source]

The DNS packet passed to from_wire() is too short.

exception dns.message.TrailingJunk(*args, **kwargs)[source]

The DNS packet passed to from_wire() has extra junk at the end of it.

exception dns.message.UnknownHeaderField(*args, **kwargs)[source]

The header field name was not recognized when converting from text into a message.

exception dns.message.UnknownTSIGKey(*args, **kwargs)[source]

A TSIG with an unknown key was received.

dns.name Exceptions

exception dns.name.AbsoluteConcatenation(*args, **kwargs)[source]

An attempt was made to append anything other than the empty name to an absolute DNS name.

exception dns.name.BadEscape(*args, **kwargs)[source]

An escaped code in a text format of DNS name is invalid.

exception dns.name.BadLabelType(*args, **kwargs)[source]

The label type in DNS name wire format is unknown.

exception dns.name.BadPointer(*args, **kwargs)[source]

A DNS compression pointer points forward instead of backward.

exception dns.name.EmptyLabel(*args, **kwargs)[source]

A DNS label is empty.

exception dns.name.IDNAException(*args, **kwargs)[source]

IDNA processing raised an exception.

exception dns.name.LabelTooLong(*args, **kwargs)[source]

A DNS label is > 63 octets long.

exception dns.name.NameTooLong(*args, **kwargs)[source]

A DNS name is > 255 octets long.

exception dns.name.NeedAbsoluteNameOrOrigin(*args, **kwargs)[source]

An attempt was made to convert a non-absolute name to wire when there was also a non-absolute (or missing) origin.

exception dns.name.NoIDNA2008(*args, **kwargs)[source]

IDNA 2008 processing was requested but the idna module is not available.

exception dns.name.NoParent(*args, **kwargs)[source]

An attempt was made to get the parent of the root name or the empty name.

dns.opcode Exceptions

exception dns.opcode.UnknownOpcode(*args, **kwargs)[source]

An DNS opcode is unknown.

dns.query Exceptions

exception dns.query.BadResponse(*args, **kwargs)[source]

A DNS query response does not respond to the question asked.

exception dns.query.NoDOH(*args, **kwargs)[source]

DNS over HTTPS (DOH) was requested but the requests module is not available.

exception dns.query.UnexpectedSource(*args, **kwargs)[source]

A DNS query response came from an unexpected address or port.

exception dns.query.TransferError(rcode)[source]

A zone transfer response got a non-zero rcode.

dns.rcode Exceptions

exception dns.rcode.UnknownRcode(*args, **kwargs)[source]

A DNS rcode is unknown.

dns.rdataset Exceptions

exception dns.rdataset.DifferingCovers(*args, **kwargs)[source]

An attempt was made to add a DNS SIG/RRSIG whose covered type is not the same as that of the other rdatas in the rdataset.

exception dns.rdataset.IncompatibleTypes(*args, **kwargs)[source]

An attempt was made to add DNS RR data of an incompatible type.

dns.resolver Exceptions

exception dns.resolver.NoAnswer(*args, **kwargs)[source]

The DNS response does not contain an answer to the question.

exception dns.resolver.NoMetaqueries(*args, **kwargs)[source]

DNS metaqueries are not allowed.

exception dns.resolver.NoNameservers(*args, **kwargs)[source]

All nameservers failed to answer the query.

errors: list of servers and respective errors The type of errors is [(server IP address, any object convertible to string)]. Non-empty errors list will add explanatory message ()

exception dns.resolver.NoRootSOA(*args, **kwargs)[source]

There is no SOA RR at the DNS root name. This should never happen!

exception dns.resolver.NotAbsolute(*args, **kwargs)[source]

An absolute domain name is required but a relative name was provided.

exception dns.resolver.NXDOMAIN(*args, **kwargs)[source]

The DNS query name does not exist.

exception dns.resolver.YXDOMAIN(*args, **kwargs)[source]

The DNS query name is too long after DNAME substitution.

dns.tokenizer Exceptions

exception dns.tokenizer.UngetBufferFull(*args, **kwargs)[source]

An attempt was made to unget a token when the unget buffer was full.

dns.ttl Exceptions

exception dns.ttl.BadTTL(*args, **kwargs)[source]

DNS TTL value is not well-formed.

dns.zone Exceptions

exception dns.zone.BadZone(*args, **kwargs)[source]

The DNS zone is malformed.

exception dns.zone.NoSOA(*args, **kwargs)[source]

The DNS zone has no SOA RR at its origin.

exception dns.zone.NoNS(*args, **kwargs)[source]

The DNS zone has no NS RRset at its origin.

exception dns.zone.UnknownOrigin(*args, **kwargs)[source]

The DNS zone’s origin is unknown.