From 75f605a676f1d93d61fa294332830c7c93267dbb Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 2 Sep 2021 13:41:44 +1000 Subject: [PATCH] Improve error text To make it clearer what the issue is. --- src/lib/waku_store/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/waku_store/index.ts b/src/lib/waku_store/index.ts index ed3d7ca513..1b2286186f 100644 --- a/src/lib/waku_store/index.ts +++ b/src/lib/waku_store/index.ts @@ -108,13 +108,15 @@ export class WakuStore { let peer; if (opts.peerId) { peer = this.libp2p.peerStore.get(opts.peerId); - if (!peer) throw 'Peer is unknown'; + if (!peer) + throw `Failed to retrieve connection details for provided peer in peer store: ${opts.peerId.toB58String()}`; } else { peer = this.randomPeer; + if (!peer) + throw 'Failed to find known peer that registers waku store protocol'; } - if (!peer) throw 'No peer available'; if (!peer.protocols.includes(StoreCodec)) - throw 'Peer does not register waku store protocol'; + throw `Peer does not register waku store protocol: ${peer.id.toB58String()}`; const connection = this.libp2p.connectionManager.get(peer.id); if (!connection) throw 'Failed to get a connection to the peer';