don't wrap exceptions with Failure

This commit is contained in:
Jack Robison 2017-10-10 13:17:36 -04:00
parent 2a47385b62
commit 3096c89e37
No known key found for this signature in database
GPG key ID: 284699E7404E3CFF

View file

@ -4,7 +4,6 @@ import socket
import errno import errno
from twisted.internet import protocol, defer, error, reactor, task from twisted.internet import protocol, defer, error, reactor, task
from twisted.python import failure
import constants import constants
import encoding import encoding
@ -379,12 +378,12 @@ class KademliaProtocol(protocol.DatagramProtocol):
kwargs = {'_rpcNodeID': senderContact.id, '_rpcNodeContact': senderContact} kwargs = {'_rpcNodeID': senderContact.id, '_rpcNodeContact': senderContact}
result = func(*args, **kwargs) result = func(*args, **kwargs)
except Exception, e: except Exception, e:
df.errback(failure.Failure(e)) df.errback(e)
else: else:
df.callback(result) df.callback(result)
else: else:
# No such exposed method # No such exposed method
df.errback(failure.Failure(AttributeError('Invalid method: %s' % method))) df.errback(AttributeError('Invalid method: %s' % method))
def _msgTimeout(self, messageID): def _msgTimeout(self, messageID):
""" Called when an RPC request message times out """ """ Called when an RPC request message times out """
@ -402,7 +401,7 @@ class KademliaProtocol(protocol.DatagramProtocol):
# The message's destination node is now considered to be dead; # The message's destination node is now considered to be dead;
# raise an (asynchronous) TimeoutError exception and update the host node # raise an (asynchronous) TimeoutError exception and update the host node
self._node.removeContact(remoteContactID) self._node.removeContact(remoteContactID)
df.errback(failure.Failure(TimeoutError(remoteContactID))) df.errback(TimeoutError(remoteContactID))
def _msgTimeoutInProgress(self, messageID, remoteContactID, df): def _msgTimeoutInProgress(self, messageID, remoteContactID, df):
# See if any progress has been made; if not, kill the message # See if any progress has been made; if not, kill the message
@ -414,7 +413,7 @@ class KademliaProtocol(protocol.DatagramProtocol):
# No progress has been made # No progress has been made
del self._partialMessagesProgress[messageID] del self._partialMessagesProgress[messageID]
del self._partialMessages[messageID] del self._partialMessages[messageID]
df.errback(failure.Failure(TimeoutError(remoteContactID))) df.errback(TimeoutError(remoteContactID))
def _hasProgressBeenMade(self, messageID): def _hasProgressBeenMade(self, messageID):
return ( return (