diff --git a/library/waku_thread/inter_thread_communication/requests/debug_node_request.nim b/library/waku_thread/inter_thread_communication/requests/debug_node_request.nim index 5d470707ac..2d7c17fddf 100644 --- a/library/waku_thread/inter_thread_communication/requests/debug_node_request.nim +++ b/library/waku_thread/inter_thread_communication/requests/debug_node_request.nim @@ -32,4 +32,5 @@ proc process*( of RETRIEVE_MY_ENR: return ok($(%*waku.node.enr.toURI())) + error "unsupported operation in DebugNodeRequest" return err("unsupported operation in DebugNodeRequest") diff --git a/library/waku_thread/inter_thread_communication/requests/discovery_request.nim b/library/waku_thread/inter_thread_communication/requests/discovery_request.nim index e23b9be26a..31ed8acfca 100644 --- a/library/waku_thread/inter_thread_communication/requests/discovery_request.nim +++ b/library/waku_thread/inter_thread_communication/requests/discovery_request.nim @@ -1,5 +1,5 @@ import std/[json, sequtils] -import chronos, results, libp2p/multiaddress +import chronos, chronicles, results, libp2p/multiaddress import ../../../../waku/factory/waku, ../../../../waku/discovery/waku_dnsdisc, @@ -117,6 +117,7 @@ proc process*( of START_DISCV5: let res = await waku.wakuDiscv5.start() res.isOkOr: + error "START_DISCV5 failed", error = error return err($error) return ok("discv5 started correctly") @@ -126,17 +127,21 @@ proc process*( return ok("discv5 stopped correctly") of GET_BOOTSTRAP_NODES: let nodes = retrieveBootstrapNodes($self[].enrTreeUrl, $self[].nameDnsServer).valueOr: + error "GET_BOOTSTRAP_NODES failed", error = error return err($error) return ok($(%*nodes)) of UPDATE_DISCV5_BOOTSTRAP_NODES: updateDiscv5BootstrapNodes($self[].nodes, waku).isOkOr: + error "UPDATE_DISCV5_BOOTSTRAP_NODES failed", error = error return err($error) return ok("discovery request processed correctly") of PEER_EXCHANGE: let numValidPeers = (await performPeerExchangeRequestTo(self[].numPeers, waku)).valueOr: + error "PEER_EXCHANGE failed", error = error return err("error calling performPeerExchangeRequestTo: " & $error) return ok($numValidPeers) + error "discovery request not handled" return err("discovery request not handled") diff --git a/library/waku_thread/inter_thread_communication/requests/node_lifecycle_request.nim b/library/waku_thread/inter_thread_communication/requests/node_lifecycle_request.nim index e47f8038e0..b581718ce6 100644 --- a/library/waku_thread/inter_thread_communication/requests/node_lifecycle_request.nim +++ b/library/waku_thread/inter_thread_communication/requests/node_lifecycle_request.nim @@ -74,14 +74,17 @@ proc process*( case self.operation of CREATE_NODE: waku[] = (await createWaku(self.configJson)).valueOr: + error "CREATE_NODE failed", error = error return err("error processing createWaku request: " & $error) of START_NODE: (await waku.startWaku()).isOkOr: + error "START_NODE failed", error = error return err("problem starting waku: " & $error) of STOP_NODE: try: await waku[].stop() except Exception: + error "STOP_NODE failed", error = getCurrentExceptionMsg() return err("exception stopping node: " & getCurrentExceptionMsg()) return ok("") diff --git a/library/waku_thread/inter_thread_communication/requests/peer_manager_request.nim b/library/waku_thread/inter_thread_communication/requests/peer_manager_request.nim index ae4ef95ade..189b490ad0 100644 --- a/library/waku_thread/inter_thread_communication/requests/peer_manager_request.nim +++ b/library/waku_thread/inter_thread_communication/requests/peer_manager_request.nim @@ -72,6 +72,7 @@ proc process*( of CONNECT_TO: let ret = waku.node.connectTo($self[].peerMultiAddr, self[].dialTimeout) if ret.isErr(): + error "CONNECT_TO failed", error = ret.error return err(ret.error) of GET_ALL_PEER_IDS: ## returns a comma-separated string of peerIDs diff --git a/library/waku_thread/inter_thread_communication/requests/protocols/lightpush_request.nim b/library/waku_thread/inter_thread_communication/requests/protocols/lightpush_request.nim index 810e938364..39d1bcac88 100644 --- a/library/waku_thread/inter_thread_communication/requests/protocols/lightpush_request.nim +++ b/library/waku_thread/inter_thread_communication/requests/protocols/lightpush_request.nim @@ -87,17 +87,22 @@ proc process*( let pubsubTopic = $self.pubsubTopic if waku.node.wakuLightpushClient.isNil(): - return err("LightpushRequest waku.node.wakuLightpushClient is nil") + let errorMsg = "LightpushRequest waku.node.wakuLightpushClient is nil" + error "PUBLISH failed", error = errorMsg + return err(errorMsg) let peerOpt = waku.node.peerManager.selectPeer(WakuLightPushCodec) if peerOpt.isNone(): - return err("failed to lightpublish message, no suitable remote peers") + let errorMsg = "failed to lightpublish message, no suitable remote peers" + error "PUBLISH failed", error = errorMsg + return err(errorMsg) ( await waku.node.wakuLightpushClient.publish( pubsubTopic, msg, peer = peerOpt.get() ) ).isOkOr: + error "PUBLISH failed", error = error return err("LightpushRequest error publishing: " & $error) return ok("") diff --git a/library/waku_thread/inter_thread_communication/requests/protocols/relay_request.nim b/library/waku_thread/inter_thread_communication/requests/protocols/relay_request.nim index ca748889e2..8672aae6dd 100644 --- a/library/waku_thread/inter_thread_communication/requests/protocols/relay_request.nim +++ b/library/waku_thread/inter_thread_communication/requests/protocols/relay_request.nim @@ -104,16 +104,20 @@ proc process*( let numPeers = await waku.node.wakuRelay.publish(pubsubTopic, msg) if numPeers == 0: - return err("Message not sent because no peers found.") + let errorMsg = "Message not sent because no peers found." + error "PUBLISH failed", error = errorMsg + return err(errorMsg) elif numPeers > 0: let msgHash = computeMessageHash(pubSubTopic, msg).to0xHex return ok(msgHash) of LIST_CONNECTED_PEERS: let numConnPeers = waku.node.wakuRelay.getNumConnectedPeers($self.pubsubTopic).valueOr: + error "LIST_CONNECTED_PEERS failed", error = error return err($error) return ok($numConnPeers) of LIST_MESH_PEERS: let numPeersInMesh = waku.node.wakuRelay.getNumPeersInMesh($self.pubsubTopic).valueOr: + error "LIST_MESH_PEERS failed", error = error return err($error) return ok($numPeersInMesh) diff --git a/library/waku_thread/inter_thread_communication/requests/protocols/store_request.nim b/library/waku_thread/inter_thread_communication/requests/protocols/store_request.nim index 2f6f8ae98d..52df4688d2 100644 --- a/library/waku_thread/inter_thread_communication/requests/protocols/store_request.nim +++ b/library/waku_thread/inter_thread_communication/requests/protocols/store_request.nim @@ -1,5 +1,5 @@ import std/[json, sugar, options] -import chronos, results +import chronos, chronicles, results import ../../../../../waku/factory/waku, ../../../../alloc, @@ -143,4 +143,5 @@ proc process*( of REMOTE_QUERY: return await cast[ptr JsonStoreQueryRequest](self[].storeReq).process(waku) + error "store request not handled at all" return err("store request not handled at all")