From ca9123c740caa6d16d84956f4019e0e5fa649bb8 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 9 Sep 2017 21:27:10 +0200 Subject: [PATCH] Add parameter to IdNotFound error --- lib/core/libimagstore/src/error.rs | 6 ++++-- lib/core/libimagstore/src/store.rs | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/core/libimagstore/src/error.rs b/lib/core/libimagstore/src/error.rs index 2f172e34..7ec504cf 100644 --- a/lib/core/libimagstore/src/error.rs +++ b/lib/core/libimagstore/src/error.rs @@ -17,6 +17,8 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // +use storeid::StoreId; + error_chain! { types { StoreError, StoreErrorKind, ResultExt, Result; @@ -69,9 +71,9 @@ error_chain! { display("ID locked") } - IdNotFound { + IdNotFound(sid: StoreId) { description("ID not found") - display("ID not found") + display("ID not found: {}", sid) } OutOfMemory { diff --git a/lib/core/libimagstore/src/store.rs b/lib/core/libimagstore/src/store.rs index 3413d905..595bdb1e 100644 --- a/lib/core/libimagstore/src/store.rs +++ b/lib/core/libimagstore/src/store.rs @@ -554,7 +554,9 @@ impl Store { Ok(e) => e, }; - let se = try!(hsmap.get_mut(&entry.location).ok_or(SE::from_kind(SEK::IdNotFound))); + let se = try!(hsmap.get_mut(&entry.location).ok_or_else(|| { + SE::from_kind(SEK::IdNotFound(entry.location.clone())) + })); assert!(se.is_borrowed(), "Tried to update a non borrowed entry.");