From e52d545126407d136b3c8d42bc9a67c0c2f8c094 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Thu, 29 Aug 2024 16:40:21 -0400 Subject: [PATCH] Convert the other Io error type to have a string of context --- gha-cache/src/api.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gha-cache/src/api.rs b/gha-cache/src/api.rs index c1852df..be93cef 100644 --- a/gha-cache/src/api.rs +++ b/gha-cache/src/api.rs @@ -75,8 +75,8 @@ pub enum Error { info: ApiErrorInfo, }, - #[error("I/O error: {0}")] - IoError(#[from] std::io::Error), + #[error("I/O error: {0}, context: {1}")] + IoError(std::io::Error, String), #[error("Too many collisions")] TooManyCollisions, @@ -345,8 +345,9 @@ impl Api { let mut futures = Vec::new(); loop { let buf = BytesMut::with_capacity(CHUNK_SIZE); - let chunk = read_chunk_async(&mut stream, buf).await?; - + let chunk = read_chunk_async(&mut stream, buf) + .await + .map_err(|e| Error::IoError(e, "Reading a chunk during upload".to_string()))?; if chunk.is_empty() { offset += chunk.len(); break;