aboutsummaryrefslogtreecommitdiff
path: root/src/recv.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-09-01 11:34:53 +0200
committerAlex Auvolat <alex@adnab.me>2022-09-01 11:34:53 +0200
commit745c78618479c4177647e4d7fed97d5fd2d00d4f (patch)
tree0f1d0dfa4bda8c4ae286ec12d726e03a55d7c2ec /src/recv.rs
parent7909a95d3c02a738c9a088c1cb8a5d6f70b06046 (diff)
downloadnetapp-745c78618479c4177647e4d7fed97d5fd2d00d4f.tar.gz
netapp-745c78618479c4177647e4d7fed97d5fd2d00d4f.zip
Also encode errorkind in stream
Diffstat (limited to 'src/recv.rs')
-rw-r--r--src/recv.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/recv.rs b/src/recv.rs
index f8d68da..f8606f3 100644
--- a/src/recv.rs
+++ b/src/recv.rs
@@ -81,9 +81,10 @@ pub(crate) trait RecvLoop: Sync + 'static {
read.read_exact(&mut next_slice[..]).await?;
let packet = if is_error {
- let msg = String::from_utf8(next_slice).unwrap_or("<invalid utf8 error message>".into());
- debug!("recv_loop: got id {}, error: {}", id, msg);
- Some(Err(std::io::Error::new(std::io::ErrorKind::Other, msg)))
+ let kind = u8_to_io_errorkind(next_slice[0]);
+ let msg = std::str::from_utf8(&next_slice[1..]).unwrap_or("<invalid utf8 error message>");
+ debug!("recv_loop: got id {}, error {:?}: {}", id, kind, msg);
+ Some(Err(std::io::Error::new(kind, msg.to_string())))
} else {
trace!(
"recv_loop: got id {}, size {}, has_cont {}",