Skip to content

Commit 7b6075e

Browse files
alexlarssonallisonkarlitskaya
authored andcommitted
repository: Add some error context
This adds error context when opening images and streams. Without this it is kinda hard to figure out what ENOENT really means. Signed-off-by: Alexander Larsson <[email protected]>
1 parent 85587ed commit 7b6075e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

crates/composefs/src/repository.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,11 @@ impl<ObjectID: FsVerityHashValue> Repository<ObjectID> {
379379
let filename = format!("streams/{name}");
380380

381381
let file = File::from(if let Some(verity_hash) = verity {
382-
self.open_with_verity(&filename, verity_hash)?
382+
self.open_with_verity(&filename, verity_hash)
383+
.with_context(|| format!("Opening ref 'streams/{name}'"))?
383384
} else {
384-
self.openat(&filename, OFlags::RDONLY)?
385+
self.openat(&filename, OFlags::RDONLY)
386+
.with_context(|| format!("Opening ref 'streams/{name}'"))?
385387
});
386388

387389
SplitStreamReader::new(file)
@@ -434,7 +436,8 @@ impl<ObjectID: FsVerityHashValue> Repository<ObjectID> {
434436
/// Returns the fd of the image and whether or not verity should be
435437
/// enabled when mounting it.
436438
fn open_image(&self, name: &str) -> Result<(OwnedFd, bool)> {
437-
let image = self.openat(&format!("images/{name}"), OFlags::RDONLY)?;
439+
let image = self.openat(&format!("images/{name}"), OFlags::RDONLY)
440+
.with_context(|| format!("Opening ref 'images/{name}'"))?;
438441

439442
if name.contains("/") {
440443
return Ok((image, true));

0 commit comments

Comments
 (0)