try with exception

This commit is contained in:
Stefan Midjich 2017-09-29 19:11:35 +02:00
parent f2b7784969
commit 6297b5abfd
1 changed files with 6 additions and 5 deletions

View File

@ -69,14 +69,15 @@ class Client(object):
# count. Don't rely on it existing though. # count. Don't rely on it existing though.
rule = None rule = None
try: try:
rule = self.find_rule(self.ip_address, self.protocol) rule = self.find_rule(self._ip_address, self.protocol)
except Exception as e: except Exception as e:
# TODO: This should raise an exception and be handled further up # TODO: This should raise an exception and be handled further up
# the stack by logging the error. # the stack by logging the error.
#raise IPTCRuleNotFound('Could not find the iptables rule for {client_ip}'.format( raise IPTCRuleNotFound(
# client_ip=self.ip_address 'Could not find the iptables rule for {client_ip}'.format(
#)) client_ip=self.ip_address
return None )
)
if rule: if rule:
(packet_count, byte_count) = rule.get_counters() (packet_count, byte_count) = rule.get_counters()