Update exception type

This commit is contained in:
Stuckinaboot
2018-10-30 00:03:19 +01:00
parent 95d3847d5a
commit 869d2db847
5 changed files with 20 additions and 10 deletions

View File

@ -32,7 +32,7 @@ class PeerStore(IPeerStore):
if peer_id in self.peer_map:
return self.peer_map[peer_id].get_protocols()
else:
raise Exception("peer ID not found")
raise PeerStoreError("peer ID not found")
def add_protocols(self, peer_id, protocols):
peer = self.__create_or_get_peer(peer_id)
@ -46,7 +46,7 @@ class PeerStore(IPeerStore):
val = self.peer_map[peer_id].get_metadata(key)
return val
else:
raise Exception("peer ID not found")
raise PeerStoreError("peer ID not found")
def put(self, peer_id, key, val):
# <<?>>
@ -66,7 +66,7 @@ class PeerStore(IPeerStore):
if peer_id in self.peer_map:
return self.peer_map[peer_id].get_addrs()
else:
raise Exception("peer ID not found")
raise PeerStoreError("peer ID not found")
def clear_addrs(self, peer_id):
# Only clear addresses if the peer is in peer map
@ -81,3 +81,7 @@ class PeerStore(IPeerStore):
if len(self.peer_map[key].get_addrs()) >= 1:
output.append(key)
return output
class PeerStoreError(KeyError):
"""Raised when peer ID is not found in peer store"""
pass