feat: enhance error handling and add precondition checks for object o… (#1008)

This commit is contained in:
0xdx2
2025-12-06 20:39:03 +08:00
committed by GitHub
parent 72930b1e30
commit 7c6cbaf837
9 changed files with 169 additions and 47 deletions

View File

@@ -41,6 +41,11 @@ pub async fn read_full<R: AsyncRead + Send + Sync + Unpin>(mut reader: R, mut bu
if total == 0 {
return Err(e);
}
// If the error is InvalidData (e.g., checksum mismatch), preserve it
// instead of wrapping it as UnexpectedEof, so proper error handling can occur
if e.kind() == std::io::ErrorKind::InvalidData {
return Err(e);
}
return Err(std::io::Error::new(
std::io::ErrorKind::UnexpectedEof,
format!("read {total} bytes, error: {e}"),