From 45382ecb74b7c00f12dec2635fb250c3e426e2c7 Mon Sep 17 00:00:00 2001 From: ghassmo Date: Thu, 19 May 2022 23:55:34 +0300 Subject: [PATCH] rpc/rpcclient: catch the error when send to closed channel --- src/rpc/rpcclient.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/rpc/rpcclient.rs b/src/rpc/rpcclient.rs index f10d9e11f..d64524346 100644 --- a/src/rpc/rpcclient.rs +++ b/src/rpc/rpcclient.rs @@ -27,7 +27,14 @@ impl RpcClient { let req_id = value.id.clone().as_u64().unwrap_or(0); let value = json!(value); - self.sender.send(value).await?; + // TODO proper error handling for closed channels + // if the connection is closed the sender will get an error + // for sending to closed channel + let result = self.sender.send(value).await; + if result.is_err() { + error!("Unable to connect to the RPC server"); + return Err(Error::OperationFailed) + } let reply = self.receiver.recv().await;