From 785e17a4a35378af1794b58d91cee9fceca04874 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 9 Sep 2017 21:52:44 +0200 Subject: [PATCH] Add param to StoreIdHasNoBaseError --- lib/core/libimagstore/src/error.rs | 4 ++-- lib/core/libimagstore/src/storeid.rs | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/core/libimagstore/src/error.rs b/lib/core/libimagstore/src/error.rs index 3c01b7a6..fec24d9e 100644 --- a/lib/core/libimagstore/src/error.rs +++ b/lib/core/libimagstore/src/error.rs @@ -184,9 +184,9 @@ error_chain! { display("Building StoreId from full file path failed") } - StoreIdHasNoBaseError { + StoreIdHasNoBaseError(pb: PathBuf) { description("StoreId has no 'base' part") - display("StoreId has no 'base' part") + display("StoreId has no 'base' part: {:?}", pb) } CreateCallError { diff --git a/lib/core/libimagstore/src/storeid.rs b/lib/core/libimagstore/src/storeid.rs index 7c3ef517..94fa3433 100644 --- a/lib/core/libimagstore/src/storeid.rs +++ b/lib/core/libimagstore/src/storeid.rs @@ -89,8 +89,9 @@ impl StoreId { /// Transform the StoreId object into a PathBuf, error if the base of the StoreId is not /// specified. - pub fn into_pathbuf(self) -> Result { - let mut base = try!(self.base.ok_or(SEK::StoreIdHasNoBaseError)); + pub fn into_pathbuf(mut self) -> Result { + let base = self.base.take(); + let mut base = try!(base.ok_or_else(|| SEK::StoreIdHasNoBaseError(self.id.clone()))); base.push(self.id); Ok(base) } @@ -346,7 +347,7 @@ mod test { let pb = id.unwrap().into_pathbuf(); assert!(pb.is_err()); - assert!(is_match!(pb.unwrap_err().kind(), &SEK::StoreIdHasNoBaseError)); + assert!(is_match!(pb.unwrap_err().kind(), &SEK::StoreIdHasNoBaseError(_))); } #[test]