From 672f0b09803627cc2c2ebd27fafb721113666f44 Mon Sep 17 00:00:00 2001 From: SionoiS Date: Thu, 21 Mar 2024 11:06:17 -0400 Subject: [PATCH] server side error handling --- waku/waku_store/protocol.nim | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/waku/waku_store/protocol.nim b/waku/waku_store/protocol.nim index e6621deb0e..504871a219 100644 --- a/waku/waku_store/protocol.nim +++ b/waku/waku_store/protocol.nim @@ -76,11 +76,21 @@ proc handleQueryRequest*( proc initProtocolHandler(self: WakuStore) = proc handler(conn: Connection, proto: string) {.async, gcsafe, closure.} = - let reqBuf = await conn.readLp(MaxRpcSize.int) + let readRes = catch: + await conn.readLp(MaxRpcSize.int) + + let reqBuf = readRes.valueOr: + error "Connection read error", error = error.msg + return let resBuf = await self.handleQueryRequest(conn.peerId, reqBuf) - await conn.writeLp(resBuf) + let writeRes = catch: + await conn.writeLp(resBuf) + + if writeRes.isErr(): + error "Connection write error", error = writeRes.error.msg + return self.handler = handler self.codec = WakuStoreCodec