From dad0255c71779cad67e356b7e71d3076aedbea03 Mon Sep 17 00:00:00 2001 From: jangko Date: Tue, 23 Jan 2024 12:10:33 +0700 Subject: [PATCH] Client pass meaningful error to newFut when processMessage failed --- json_rpc/clients/httpclient.nim | 5 +++-- json_rpc/servers/websocketserver.nim | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/json_rpc/clients/httpclient.nim b/json_rpc/clients/httpclient.nim index 2e419f7..02ca22b 100644 --- a/json_rpc/clients/httpclient.nim +++ b/json_rpc/clients/httpclient.nim @@ -152,10 +152,11 @@ method call*(client: RpcHttpClient, name: string, if msgRes.isErr: # Need to clean up in case the answer was invalid debug "Failed to process POST Response for JSON-RPC", msg = msgRes.error - newFut.cancelSoon() + let exc = newException(JsonRpcError, msgRes.error) + newFut.fail(exc) client.awaiting.del(id) closeRefs() - raise newException(JsonRpcError, msgRes.error) + raise exc client.awaiting.del(id) diff --git a/json_rpc/servers/websocketserver.nim b/json_rpc/servers/websocketserver.nim index 3789375..e61e3a9 100644 --- a/json_rpc/servers/websocketserver.nim +++ b/json_rpc/servers/websocketserver.nim @@ -86,7 +86,7 @@ proc handleRequest(rpc: RpcWebSocketServer, request: HttpRequest) {.async: (rais debug "Internal error, while processing RPC call", address = $request.uri await ws.close( - reason = "Internal error, while processing RPC call" + reason = "Internal error, while processing RPC call: " & exc.msg ) break