root / trunk / twisted / names / error.py

Revision 18817, 1.8 kB (checked in by exarkun, 3 years ago)

Merge resolver-error-reporting-2248

Author: exarkun
Reviewer: radix
Fixes #2248

Change the resolver client API to translate DNS response codes other than OK
into Failures passed to a Deferred errback. Add several new exception classes
to represent the different response codes which are possible and a new module
for twisted.names exception classes.

This is a not a backwards compatible change. Instead of being passed a three
tuple of empty lists on error, callers of lookup methods will now have their
Deferred errback instead.

Also update twisted.mail.relaymanager.MXCalculator to account for this change,
since it relied on checks against the empty list to discover the failure case.

Line 
1 # -*- test-case-name: twisted.names.test -*-
2 # Copyright (c) 2001-2004 Twisted Matrix Laboratories.
3 # See LICENSE for details.
4
5 """
6 Exception class definitions for Twisted Names.
7 """
8
9 from twisted.internet.defer import TimeoutError
10
11
12 class DomainError(ValueError):
13     """
14     Indicates a lookup failed because there were no records matching the given
15     C{name, class, type} triple.
16     """
17
18
19
20 class AuthoritativeDomainError(ValueError):
21     """
22     Indicates a lookup failed for a name for which this server is authoritative
23     because there were no records matching the given C{name, class, type}
24     triple.
25     """
26
27
28
29 class DNSQueryTimeoutError(TimeoutError):
30     """
31     Indicates a lookup failed due to a timeout.
32
33     @ivar id: The id of the message which timed out.
34     """
35     def __init__(self, id):
36         TimeoutError.__init__(self)
37         self.id = id
38
39
40
41 class DNSFormatError(DomainError):
42     """
43     Indicates a query failed with a result of L{twisted.names.dns.EFORMAT}.
44     """
45
46
47
48 class DNSServerError(DomainError):
49     """
50     Indicates a query failed with a result of L{twisted.names.dns.ESERVER}.
51     """
52
53
54
55 class DNSNameError(DomainError):
56     """
57     Indicates a query failed with a result of L{twisted.names.dns.ENAME}.
58     """
59
60
61
62 class DNSNotImplementedError(DomainError):
63     """
64     Indicates a query failed with a result of L{twisted.names.dns.ENOTIMP}.
65     """
66
67
68
69 class DNSQueryRefusedError(DomainError):
70     """
71     Indicates a query failed with a result of L{twisted.names.dns.EREFUSED}.
72     """
73
74
75
76 class DNSUnknownError(DomainError):
77     """
78     Indicates a query failed with an unknown result.
79     """
80
81
82
83 __all__ = [
84     'DomainError', 'AuthoritativeDomainError', 'DNSQueryTimeoutError',
85
86     'DNSFormatError', 'DNSServerError', 'DNSNameError',
87     'DNSNotImplementedError', 'DNSQueryRefusedError',
88     'DNSUnknownError']
Note: See TracBrowser for help on using the browser.