Skip to content

Commit 379261f

Browse files
committed
Add missing "path context" for more IO failures
Whenever a _user configurable_ path is not found, this currently prints a useless "File not found" without any additional context _which_ path was attempted nor where it was configured. By explaining what we're doing in the error messages, users are more likely to know what and where to correct.
1 parent f7c8252 commit 379261f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

xbuild/src/command/build.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,12 @@ pub fn build(env: &BuildEnv) -> Result<()> {
149149
.package_root()
150150
.join(runtime_lib_path)
151151
.join(target.android_abi().android_abi());
152-
let entries = std::fs::read_dir(abi_dir)?;
152+
let entries = std::fs::read_dir(&abi_dir).with_context(|| {
153+
format!(
154+
"Runtime libraries for current ABI not found at `{}`",
155+
abi_dir.display()
156+
)
157+
})?;
153158
for entry in entries {
154159
let entry = entry?;
155160
let path = entry.path();

xcommon/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ pub struct Scaler {
2323

2424
impl Scaler {
2525
pub fn open<P: AsRef<Path>>(path: P) -> Result<Self> {
26-
let img = ImageReader::open(path)?.decode()?;
26+
let path = path.as_ref();
27+
let img = ImageReader::open(path)
28+
.with_context(|| format!("Scaler failed to open image at `{}`", path.display()))?
29+
.decode()?;
2730
let (width, height) = img.dimensions();
2831
anyhow::ensure!(width == height, "expected width == height");
2932
anyhow::ensure!(width >= 512, "expected icon of at least 512x512 px");

0 commit comments

Comments
 (0)