From ebe8d849d689a305aef0bb5e3be8fec361c61910 Mon Sep 17 00:00:00 2001 From: yggverse Date: Wed, 20 Nov 2024 08:52:25 +0200 Subject: [PATCH] add id info to error enums --- src/profile/identity/gemini/memory.rs | 4 ++-- src/profile/identity/gemini/memory/error.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/profile/identity/gemini/memory.rs b/src/profile/identity/gemini/memory.rs index 52cd78e9..32ddb2f3 100644 --- a/src/profile/identity/gemini/memory.rs +++ b/src/profile/identity/gemini/memory.rs @@ -24,7 +24,7 @@ impl Memory { /// * validate record with same key does not exist yet pub fn add(&self, id: i64, pem: String) -> Result<(), Error> { match self.index.borrow_mut().insert(id, pem) { - Some(_) => Err(Error::Overwrite), // @TODO prevent? + Some(_) => Err(Error::Overwrite(id)), // @TODO prevent? None => Ok(()), } } @@ -33,7 +33,7 @@ impl Memory { pub fn get(&self, id: i64) -> Result { match self.index.borrow().get(&id) { Some(pem) => Ok(pem.clone()), - None => Err(Error::NotFound), + None => Err(Error::NotFound(id)), } } diff --git a/src/profile/identity/gemini/memory/error.rs b/src/profile/identity/gemini/memory/error.rs index 09edab81..83f64a5d 100644 --- a/src/profile/identity/gemini/memory/error.rs +++ b/src/profile/identity/gemini/memory/error.rs @@ -1,5 +1,5 @@ #[derive(Debug)] pub enum Error { - NotFound, - Overwrite, + NotFound(i64), + Overwrite(i64), }