Catch PeerDataError
in PeerStore.get
This commit is contained in:
parent
5063f0e2a6
commit
211e2f6dd0
|
@ -3,7 +3,7 @@ from typing import Any, Dict, List, Optional, Sequence
|
||||||
from multiaddr import Multiaddr
|
from multiaddr import Multiaddr
|
||||||
|
|
||||||
from .id import ID
|
from .id import ID
|
||||||
from .peerdata import PeerData
|
from .peerdata import PeerData, PeerDataError
|
||||||
from .peerinfo import PeerInfo
|
from .peerinfo import PeerInfo
|
||||||
from .peerstore_interface import IPeerStore
|
from .peerstore_interface import IPeerStore
|
||||||
|
|
||||||
|
@ -54,7 +54,10 @@ class PeerStore(IPeerStore):
|
||||||
|
|
||||||
def get(self, peer_id: ID, key: str) -> Any:
|
def get(self, peer_id: ID, key: str) -> Any:
|
||||||
if peer_id in self.peer_map:
|
if peer_id in self.peer_map:
|
||||||
|
try:
|
||||||
val = self.peer_map[peer_id].get_metadata(key)
|
val = self.peer_map[peer_id].get_metadata(key)
|
||||||
|
except PeerDataError as error:
|
||||||
|
raise PeerStoreError(error)
|
||||||
return val
|
return val
|
||||||
raise PeerStoreError("peer ID not found")
|
raise PeerStoreError("peer ID not found")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user