Commit 3c3c6425 authored by Alexandre's avatar Alexandre
Browse files

Define new Exceptions

parent 8cba1a31
......@@ -301,6 +301,16 @@ class ConnectionDOHException(ConnectionException):
class FamilyException(ConnectionException):
pass
class RequestException(Exception):
pass
class RequestDOTException(RequestException):
pass
class PipeliningException(Exception):
pass
class Request:
def __init__(self, qname, qtype='AAAA', use_edns=True, want_dnssec=False, no_ecs=True):
if no_ecs:
......@@ -327,7 +337,7 @@ class RequestDOT(Request):
# raising custom exception for each unexpected response might be a good idea
def check_response(self, debug=False):
if self.response is None:
raise Exception("No reply received")
raise RequestDOTException("No reply received")
ok = self.ok
if not self.rcode:
self.ok = False
......@@ -658,7 +668,7 @@ class ConnectionDOT(Connection):
response = dns.message.from_wire(data)
id = response.id
if id not in requests:
raise Exception("Received response for ID %s which is unexpected" % id)
raise PipeliningException("Received response for ID %s which is unexpected" % id)
over, rank, request = requests[id]
self.all_requests[rank]['response'] = (rcode, response, size)
requests[id] = (True, rank, request)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment