Skip to content

Commit fff41b1

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 e30bba6 commit fff41b1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

crates/composefs/src/repository.rs

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

333333
let file = File::from(if let Some(verity_hash) = verity {
334-
self.open_with_verity(&filename, verity_hash)?
334+
self.open_with_verity(&filename, verity_hash)
335+
.with_context(|| format!("Opening ref 'streams/{name}'"))?
335336
} else {
336-
self.openat(&filename, OFlags::RDONLY)?
337+
self.openat(&filename, OFlags::RDONLY)
338+
.with_context(|| format!("Opening ref 'streams/{name}'"))?
337339
});
338340

339341
SplitStreamReader::new(file)
@@ -384,7 +386,9 @@ impl<ObjectID: FsVerityHashValue> Repository<ObjectID> {
384386
}
385387

386388
pub fn open_image(&self, name: &str) -> Result<OwnedFd> {
387-
let image = self.openat(&format!("images/{name}"), OFlags::RDONLY)?;
389+
let image = self
390+
.openat(&format!("images/{name}"), OFlags::RDONLY)
391+
.with_context(|| format!("Opening ref 'images/{name}'"))?;
388392

389393
if !name.contains("/") {
390394
// A name with no slashes in it is taken to be a sha256 fs-verity digest

0 commit comments

Comments
 (0)