more detailed errors

This commit is contained in:
FallBackITA27
2024-07-11 13:23:35 +02:00
parent 2979280fd3
commit 288cf0b196

View File

@@ -49,9 +49,13 @@ pub async fn download_file_progress(
let mut stream = res.bytes_stream(); let mut stream = res.bytes_stream();
while let Some(item) = stream.next().await { while let Some(item) = stream.next().await {
let chunk = item.or(Err("Error while downloading file"))?; let chunk = match item {
file.write_all(&chunk) Ok(v) => v,
.or(Err("Error while writing to file"))?; Err(e) => return Err(format!("Error while downloading file: {e}"))
};
if let Err(e) = file.write_all(&chunk) {
Err(format!("Error while writing to file: {e}"))?
}
let new = min(downloaded + (chunk.len() as u64), total_size); let new = min(downloaded + (chunk.len() as u64), total_size);
downloaded = new; downloaded = new;
pb.set_position(new); pb.set_position(new);