Relaxed outbound error handling
This commit is contained in:
parent
06a43f6515
commit
a2e856762c
@ -175,6 +175,9 @@ class Packet:
|
|||||||
self.packed = False
|
self.packed = False
|
||||||
self.updateHash()
|
self.updateHash()
|
||||||
|
|
||||||
|
# Sends the packet. Returns a receipt if one is generated,
|
||||||
|
# or None if no receipt is available. Returns False if the
|
||||||
|
# packet could not be sent.
|
||||||
def send(self):
|
def send(self):
|
||||||
if not self.sent:
|
if not self.sent:
|
||||||
if self.destination.type == RNS.Destination.LINK:
|
if self.destination.type == RNS.Destination.LINK:
|
||||||
@ -191,9 +194,11 @@ class Packet:
|
|||||||
if RNS.Transport.outbound(self):
|
if RNS.Transport.outbound(self):
|
||||||
return self.receipt
|
return self.receipt
|
||||||
else:
|
else:
|
||||||
# TODO: Decide whether this failure should simply
|
RNS.log("No interfaces could process the outbound packet", RNS.LOG_ERROR)
|
||||||
# return none, or raise an error
|
self.sent = False
|
||||||
raise IOError("No interfaces could process the outbound packet")
|
self.receipt = None
|
||||||
|
return False
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise IOError("Packet was already sent")
|
raise IOError("Packet was already sent")
|
||||||
|
|
||||||
@ -202,8 +207,10 @@ class Packet:
|
|||||||
if RNS.Transport.outbound(self):
|
if RNS.Transport.outbound(self):
|
||||||
return self.receipt
|
return self.receipt
|
||||||
else:
|
else:
|
||||||
# TODO: Don't raise error here, handle gracefully
|
RNS.log("No interfaces could process the outbound packet", RNS.LOG_ERROR)
|
||||||
raise IOError("Packet could not be sent! Do you have any outbound interfaces configured?")
|
self.sent = False
|
||||||
|
self.receipt = None
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
raise IOError("Packet was not sent yet")
|
raise IOError("Packet was not sent yet")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user