Change the Error handling and remove unsed code

This commit is contained in:
schwente 2016-06-08 12:54:11 +02:00
parent 11b0622804
commit 21fa21859b

View file

@ -1,9 +1,3 @@
// Needed for reading a Json File
// extern crate rustc_serialize;
// use rustc_serialize::json::Json;
// use std::fs::File;
// use std::io::Read;
use uuid::Uuid;
use libimagstore::store::Store;
@ -12,22 +6,14 @@ use module_path::ModuleEntryPath;
use error::{TodoError, TodoErrorKind};
/// With the uuid we get the storeid and than we can delete the entry
pub fn deleteFunc(uuid: Uuid, store : &Store) {
// With this we can read from a .json File
// let mut file = File::open("text.json").unwrap();
// let mut data = String::new();
// file.rad_to_string(&mut data).unwrap();
//
// let jeson = Json::from_str(&data).unwrap();
// println!("{}", json.find_path(&["uuid"]).unwrap());
/// With the uuid we get the storeid and then we can delete the entry
pub fn deleteFunc(uuid: Uuid, store : &Store) -> Result<(),TodoError> {
// With the uuid we get the storeid
let store_id = ModuleEntryPath::new(format!("taskwarrior/{}", uuid)).into_storeid();
// It deletes an entry
if let Err(e) = store.delete(store_id) {
return Err(TodoError::new(TodoErrorKind::StoreError, Some(Box::new(e)))).unwrap();
}
match store.delete(store_id) {
Ok(val) => Ok(val),
Err(e) => Err(TodoError::new(TodoErrorKind::StoreError, Some(Box::new(e)))),
}
}