mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-26 07:21:36 +00:00
fix: reject rather than throw in get peer info (#410)
The get peer info util consolidation from #400 exposed an issue with how bad values are being handled. Throwing the error can cause issues when promises are being used. Rejecting resolves this. I added a test case to validate the change.
This commit is contained in:
@ -56,10 +56,10 @@ function getPeerInfoRemote (peer, libp2p) {
|
||||
try {
|
||||
peerInfo = getPeerInfo(peer, libp2p.peerBook)
|
||||
} catch (err) {
|
||||
throw errCode(
|
||||
return Promise.reject(errCode(
|
||||
new Error(`${peer} is not a valid peer type`),
|
||||
'ERR_INVALID_PEER_TYPE'
|
||||
)
|
||||
))
|
||||
}
|
||||
|
||||
// If we don't have an address for the peer, attempt to find it
|
||||
|
Reference in New Issue
Block a user