mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
add id info to error enums
This commit is contained in:
parent
755a704433
commit
ebe8d849d6
@ -24,7 +24,7 @@ impl Memory {
|
|||||||
/// * validate record with same key does not exist yet
|
/// * validate record with same key does not exist yet
|
||||||
pub fn add(&self, id: i64, pem: String) -> Result<(), Error> {
|
pub fn add(&self, id: i64, pem: String) -> Result<(), Error> {
|
||||||
match self.index.borrow_mut().insert(id, pem) {
|
match self.index.borrow_mut().insert(id, pem) {
|
||||||
Some(_) => Err(Error::Overwrite), // @TODO prevent?
|
Some(_) => Err(Error::Overwrite(id)), // @TODO prevent?
|
||||||
None => Ok(()),
|
None => Ok(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ impl Memory {
|
|||||||
pub fn get(&self, id: i64) -> Result<String, Error> {
|
pub fn get(&self, id: i64) -> Result<String, Error> {
|
||||||
match self.index.borrow().get(&id) {
|
match self.index.borrow().get(&id) {
|
||||||
Some(pem) => Ok(pem.clone()),
|
Some(pem) => Ok(pem.clone()),
|
||||||
None => Err(Error::NotFound),
|
None => Err(Error::NotFound(id)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
NotFound,
|
NotFound(i64),
|
||||||
Overwrite,
|
Overwrite(i64),
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user