Convert the other Io error type to have a string of context

This commit is contained in:
Graham Christensen 2024-08-29 16:40:21 -04:00
parent edb35e8b94
commit e52d545126

View file

@ -75,8 +75,8 @@ pub enum Error {
info: ApiErrorInfo, info: ApiErrorInfo,
}, },
#[error("I/O error: {0}")] #[error("I/O error: {0}, context: {1}")]
IoError(#[from] std::io::Error), IoError(std::io::Error, String),
#[error("Too many collisions")] #[error("Too many collisions")]
TooManyCollisions, TooManyCollisions,
@ -345,8 +345,9 @@ impl Api {
let mut futures = Vec::new(); let mut futures = Vec::new();
loop { loop {
let buf = BytesMut::with_capacity(CHUNK_SIZE); 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() { if chunk.is_empty() {
offset += chunk.len(); offset += chunk.len();
break; break;