Skip to content

Commit 215b256

Browse files
committed
async:when the client request failed. Learn from ttrpc-go
The error type shuld more friendly to external interfaces Signed-off-by: jokemanfire <hu.dingyang@zte.com.cn>
1 parent 0210c7a commit 215b256

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/asynchronous/client.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,20 @@ impl Client {
8484
self.req_tx
8585
.send(SendingMessage::new(msg))
8686
.await
87-
.map_err(|e| Error::Others(format!("Send packet to sender error {e:?}")))?;
87+
.map_err(|_| Error::LocalClosed)?;
8888

8989
let result = if timeout_nano == 0 {
9090
rx.recv()
9191
.await
92-
.ok_or_else(|| Error::Others("Receive packet from receiver error".to_string()))?
92+
.ok_or_else(|| Error::RemoteClosed)?
9393
} else {
9494
tokio::time::timeout(
9595
std::time::Duration::from_nanos(timeout_nano as u64),
9696
rx.recv(),
9797
)
9898
.await
9999
.map_err(|e| Error::Others(format!("Receive packet timeout {e:?}")))?
100-
.ok_or_else(|| Error::Others("Receive packet from receiver error".to_string()))?
100+
.ok_or_else(|| Error::RemoteClosed)?
101101
};
102102

103103
let msg = result?;

0 commit comments

Comments
 (0)