io/region: add chunk coords to error descriptions

This commit is contained in:
Matthias Schiffer 2023-01-29 17:08:39 +01:00
parent 1d126ba771
commit 92a9bb3bb3
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C

View file

@ -98,16 +98,18 @@ impl<R: Read + Seek> Region<R> {
}; };
if seen[coords] { if seen[coords] {
bail!("Duplicate chunk"); bail!("Duplicate chunk {:?}", coords);
} }
seen[coords] = true; seen[coords] = true;
let mut buffer = vec![0; (len as usize) * BLOCKSIZE]; let mut buffer = vec![0; (len as usize) * BLOCKSIZE];
reader reader
.read_exact(&mut buffer) .read_exact(&mut buffer)
.context("Failed to read chunk data")?; .with_context(|| format!("Failed to read data for chunk {:?}", coords))?;
let chunk = decode_chunk(&buffer)
.with_context(|| format!("Failed to decode data for chunk {:?}", coords))?;
f(coords, decode_chunk(&buffer)?); f(coords, chunk);
index += len as u32; index += len as u32;
} }