diff --git a/rust/lanzatool/src/pe.rs b/rust/lanzatool/src/pe.rs index d2d0188..2101b43 100644 --- a/rust/lanzatool/src/pe.rs +++ b/rust/lanzatool/src/pe.rs @@ -205,5 +205,13 @@ fn image_base(pe: &PE) -> u64 { } fn file_size(path: impl AsRef) -> Result { - Ok(fs::File::open(path)?.metadata()?.size()) + Ok(fs::File::open(&path) + .with_context(|| { + format!( + "Failed to read file to calculate its size: {:?}", + path.as_ref() + ) + })? + .metadata()? + .size()) }