aboutsummaryrefslogtreecommitdiff
path: root/src/recv.rs
diff options
context:
space:
mode:
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 {}",