Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing "path context" for more IO failures #177

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion xbuild/src/command/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,12 @@ pub fn build(env: &BuildEnv) -> Result<()> {
.package_root()
.join(runtime_lib_path)
.join(target.android_abi().android_abi());
let entries = std::fs::read_dir(abi_dir)?;
let entries = std::fs::read_dir(&abi_dir).with_context(|| {
format!(
"Runtime libraries for current ABI not found at `{}`",
abi_dir.display()
)
})?;
for entry in entries {
let entry = entry?;
let path = entry.path();
Expand Down
5 changes: 4 additions & 1 deletion xcommon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ pub struct Scaler {

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