From: Ian Jackson Date: Sun, 10 Jan 2021 21:24:06 +0000 (+0000) Subject: LibraryItemNotFound: Include item name in error X-Git-Tag: otter-0.3.0~114 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=7f5d60dff046e78e66e82f1767d5416475d1a0da;p=otter.git LibraryItemNotFound: Include item name in error Signed-off-by: Ian Jackson --- diff --git a/src/shapelib.rs b/src/shapelib.rs index 54fea79a..df4054b3 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -224,7 +224,8 @@ impl ItemSpec { #[throws(SpecError)] pub fn load(&self) -> Box { let lib = libs_lookup(&self.lib)?; - let idata = lib.items.get(&self.item).ok_or(SE::LibraryItemNotFound)?; + let idata = lib.items.get(&self.item) + .ok_or(SE::LibraryItemNotFound(self.item.clone()))?; lib.load1(idata, &self.item)? } } @@ -237,7 +238,7 @@ impl Contents { .map_err(|e| if e.kind() == ErrorKind::NotFound { warn!("library item lib={} itme={} data file {:?} not found", &self.libname, &name, &svg_path); - SE::LibraryItemNotFound + SE::LibraryItemNotFound(name.to_owned()) } else { let m = "error accessing/reading library item data file"; error!("{}: {}: {}", &m, &svg_path, &e); @@ -280,7 +281,7 @@ impl Contents { for (k,v) in &self.items { if !pat.matches(&k) { continue } let loaded = match self.load1(v, &k) { - Err(SpecError::LibraryItemNotFound) => continue, + Err(SpecError::LibraryItemNotFound(_)) => continue, e@ Err(_) => e?, Ok(r) => r, }; diff --git a/src/spec.rs b/src/spec.rs index 2c01f014..73b8ed17 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -66,7 +66,7 @@ pub enum SpecError { InternalError(String), PosOffTable, LibraryNotFound, - LibraryItemNotFound, + LibraryItemNotFound(String), AclInvalidAccountGlob, AclEntryOverlappingAllowDeny, InconsistentPieceCount,