diff --git a/imag-counter/src/list.rs b/imag-counter/src/list.rs index 2d1c80bb..b7276957 100644 --- a/imag-counter/src/list.rs +++ b/imag-counter/src/list.rs @@ -15,11 +15,11 @@ pub fn list(rt: &Runtime) { let value = c.value(); if name.is_err() { - trace_error(&name.err().unwrap()); + trace_error(&name.unwrap_err()); } else { if value.is_err() { - trace_error(&value.err().unwrap()); + trace_error(&value.unwrap_err()); } else { println!("{} - {}", name.unwrap(), value.unwrap()); } diff --git a/imag-counter/src/main.rs b/imag-counter/src/main.rs index 964556e3..538149dc 100644 --- a/imag-counter/src/main.rs +++ b/imag-counter/src/main.rs @@ -59,7 +59,7 @@ fn main() { rt.unwrap() } else { println!("Could not set up Runtime"); - println!("{:?}", rt.err().unwrap()); + println!("{:?}", rt.unwrap_err()); exit(1); } }; diff --git a/imag-link/src/main.rs b/imag-link/src/main.rs index d20bbac3..70f1d019 100644 --- a/imag-link/src/main.rs +++ b/imag-link/src/main.rs @@ -53,7 +53,7 @@ fn main() { rt.unwrap() } else { println!("Could not set up Runtime"); - println!("{:?}", rt.err().unwrap()); + println!("{:?}", rt.unwrap_err()); exit(1); } }; @@ -200,7 +200,7 @@ fn handle_external_linking(rt: &Runtime) { let entry_name = scmd.value_of("id").unwrap(); // enforced by clap let entry = get_entry_by_name(rt, entry_name); if entry.is_err() { - trace_error(&entry.err().unwrap()); + trace_error(&entry.unwrap_err()); exit(1); } let mut entry = entry.unwrap(); @@ -238,7 +238,7 @@ fn add_link_to_entry(store: &Store, matches: &ArgMatches, entry: &mut FileLockEn let link = Url::parse(link); if link.is_err() { debug!("URL parsing error..."); - trace_error(&link.err().unwrap()); + trace_error(&link.unwrap_err()); debug!("Exiting"); exit(1); } @@ -258,7 +258,7 @@ fn remove_link_from_entry(store: &Store, matches: &ArgMatches, entry: &mut FileL let link = Url::parse(link); if link.is_err() { - trace_error(&link.err().unwrap()); + trace_error(&link.unwrap_err()); exit(1); } let link = link.unwrap(); diff --git a/imag-notes/src/main.rs b/imag-notes/src/main.rs index 1c6dedfb..bea757fa 100644 --- a/imag-notes/src/main.rs +++ b/imag-notes/src/main.rs @@ -29,7 +29,7 @@ fn main() { rt.unwrap() } else { println!("Could not set up Runtime"); - println!("{:?}", rt.err().unwrap()); + println!("{:?}", rt.unwrap_err()); exit(1); } }; @@ -81,7 +81,7 @@ fn edit(rt: &Runtime) { fn edit_entry(rt: &Runtime, name: String) -> bool { let note = Note::retrieve(rt.store(), name); if note.is_err() { - trace_error(¬e.err().unwrap()); + trace_error(¬e.unwrap_err()); warn!("Cannot edit nonexistent Note"); return false } @@ -100,7 +100,7 @@ fn list(rt: &Runtime) { let iter = Note::all_notes(rt.store()); if iter.is_err() { - trace_error(&iter.err().unwrap()); + trace_error(&iter.unwrap_err()); exit(1); } diff --git a/imag-store/src/create.rs b/imag-store/src/create.rs index 9921bb05..a8b85ad3 100644 --- a/imag-store/src/create.rs +++ b/imag-store/src/create.rs @@ -38,7 +38,7 @@ pub fn create(rt: &Runtime) { let path = build_entry_path(rt.store(), path.unwrap()); if path.is_err() { - trace_error(&path.err().unwrap()); + trace_error(&path.unwrap_err()); exit(1); } let path = path.unwrap(); diff --git a/imag-store/src/delete.rs b/imag-store/src/delete.rs index 5386903e..0c59fc37 100644 --- a/imag-store/src/delete.rs +++ b/imag-store/src/delete.rs @@ -12,7 +12,7 @@ pub fn delete(rt: &Runtime) { .map(|id| { let path = build_entry_path(rt.store(), id); if path.is_err() { - trace_error(&path.err().unwrap()); + trace_error(&path.unwrap_err()); exit(1); } let path = path.unwrap(); diff --git a/imag-store/src/main.rs b/imag-store/src/main.rs index 679390e3..a1e9e09a 100644 --- a/imag-store/src/main.rs +++ b/imag-store/src/main.rs @@ -51,7 +51,7 @@ fn main() { rt.unwrap() } else { println!("Could not set up Runtime"); - println!("{:?}", rt.err().unwrap()); + println!("{:?}", rt.unwrap_err()); exit(1); } }; diff --git a/imag-store/src/retrieve.rs b/imag-store/src/retrieve.rs index f5225a46..01c54bad 100644 --- a/imag-store/src/retrieve.rs +++ b/imag-store/src/retrieve.rs @@ -17,7 +17,7 @@ pub fn retrieve(rt: &Runtime) { .map(|id| { let path = build_entry_path(rt.store(), id); if path.is_err() { - trace_error(&path.err().unwrap()); + trace_error(&path.unwrap_err()); exit(1); } let path = path.unwrap(); diff --git a/imag-store/src/update.rs b/imag-store/src/update.rs index 287624c5..311ce138 100644 --- a/imag-store/src/update.rs +++ b/imag-store/src/update.rs @@ -15,7 +15,7 @@ pub fn update(rt: &Runtime) { .map(|id| { let path = build_entry_path(rt.store(), id); if path.is_err() { - trace_error(&path.err().unwrap()); + trace_error(&path.unwrap_err()); exit(1); } let path = path.unwrap(); diff --git a/imag-tag/src/main.rs b/imag-tag/src/main.rs index 2b6201dc..e1a35a34 100644 --- a/imag-tag/src/main.rs +++ b/imag-tag/src/main.rs @@ -32,7 +32,7 @@ fn main() { rt.unwrap() } else { println!("Could not set up Runtime"); - println!("{:?}", rt.err().unwrap()); + println!("{:?}", rt.unwrap_err()); exit(1); } }; @@ -127,7 +127,7 @@ fn list(id: &str, rt: &Runtime) { if entry.is_err() { debug!("Could not retrieve '{:?}' => {:?}", id, path); warn!("Could not retrieve entry '{}'", id); - trace_error(&entry.err().unwrap()); + trace_error(&entry.unwrap_err()); exit(1); } let entry = entry.unwrap(); @@ -146,7 +146,7 @@ fn list(id: &str, rt: &Runtime) { let tags = entry.get_tags(); if tags.is_err() { - trace_error(&tags.err().unwrap()); + trace_error(&tags.unwrap_err()); exit(1); } let tags = tags.unwrap(); diff --git a/imag-view/src/main.rs b/imag-view/src/main.rs index 1f18ca17..f12e639d 100644 --- a/imag-view/src/main.rs +++ b/imag-view/src/main.rs @@ -54,7 +54,7 @@ fn main() { rt.unwrap() } else { println!("Could not set up Runtime"); - println!("{:?}", rt.err().unwrap()); + println!("{:?}", rt.unwrap_err()); exit(1); // we can afford not-executing destructors here } }; @@ -102,7 +102,7 @@ fn main() { let entry = load_entry(entry_id, entry_version, &rt); if entry.is_err() { - trace_error(&entry.err().unwrap()); + trace_error(&entry.unwrap_err()); exit(1); // we can afford not-executing destructors here } let entry = entry.unwrap(); diff --git a/libimagcounter/src/counter.rs b/libimagcounter/src/counter.rs index bea7537e..2285071f 100644 --- a/libimagcounter/src/counter.rs +++ b/libimagcounter/src/counter.rs @@ -39,17 +39,17 @@ impl<'a> Counter<'a> { let mut header = entry.get_header_mut(); let setres = header.set("counter", Value::Table(BTreeMap::new())); if setres.is_err() { - return Err(CE::new(CEK::StoreWriteError, Some(Box::new(setres.err().unwrap())))); + return Err(CE::new(CEK::StoreWriteError, Some(Box::new(setres.unwrap_err())))); } let setres = header.set("counter.name", Value::String(name)); if setres.is_err() { - return Err(CE::new(CEK::StoreWriteError, Some(Box::new(setres.err().unwrap())))); + return Err(CE::new(CEK::StoreWriteError, Some(Box::new(setres.unwrap_err())))); } let setres = header.set("counter.value", Value::Integer(init)); if setres.is_err() { - return Err(CE::new(CEK::StoreWriteError, Some(Box::new(setres.err().unwrap())))); + return Err(CE::new(CEK::StoreWriteError, Some(Box::new(setres.unwrap_err())))); } } diff --git a/libimagentrylink/src/external.rs b/libimagentrylink/src/external.rs index 8c1e5b01..e99abf42 100644 --- a/libimagentrylink/src/external.rs +++ b/libimagentrylink/src/external.rs @@ -170,7 +170,7 @@ impl ExternalLinker for Entry { let file = store.retrieve(file_id.clone()); if file.is_err() { debug!("Failed to create or retrieve an file for this link '{:?}'", link); - return Err(LE::new(LEK::StoreWriteError, Some(Box::new(file.err().unwrap())))); + return Err(LE::new(LEK::StoreWriteError, Some(Box::new(file.unwrap_err())))); } let mut file = file.unwrap(); diff --git a/libimagentrylink/src/internal.rs b/libimagentrylink/src/internal.rs index e22214d1..a410349a 100644 --- a/libimagentrylink/src/internal.rs +++ b/libimagentrylink/src/internal.rs @@ -139,7 +139,7 @@ fn process_rw_result(links: StoreResult>) -> Result> { if links.is_err() { debug!("RW action on store failed. Generating LinkError"); let lerr = LinkError::new(LinkErrorKind::EntryHeaderReadError, - Some(Box::new(links.err().unwrap()))); + Some(Box::new(links.unwrap_err()))); return Err(lerr); } let links = links.unwrap(); diff --git a/libimagentrytag/src/tagable.rs b/libimagentrytag/src/tagable.rs index bd478a97..4dbe4efb 100644 --- a/libimagentrytag/src/tagable.rs +++ b/libimagentrytag/src/tagable.rs @@ -31,7 +31,7 @@ impl Tagable for EntryHeader { let tags = self.read("imag.tags"); if tags.is_err() { let kind = TagErrorKind::HeaderReadError; - return Err(TagError::new(kind, Some(Box::new(tags.err().unwrap())))); + return Err(TagError::new(kind, Some(Box::new(tags.unwrap_err())))); } let tags = tags.unwrap(); @@ -106,7 +106,7 @@ impl Tagable for EntryHeader { let tags = self.read("imag.tags"); if tags.is_err() { let kind = TagErrorKind::HeaderReadError; - return Err(TagError::new(kind, Some(Box::new(tags.err().unwrap())))); + return Err(TagError::new(kind, Some(Box::new(tags.unwrap_err())))); } let tags = tags.unwrap(); @@ -129,7 +129,7 @@ impl Tagable for EntryHeader { for tag in tags { let check = self.has_tag(tag); if check.is_err() { - return Err(check.err().unwrap()); + return Err(check.unwrap_err()); } let check = check.unwrap(); diff --git a/libimagnotes/src/note.rs b/libimagnotes/src/note.rs index aa186ef2..2728b768 100644 --- a/libimagnotes/src/note.rs +++ b/libimagnotes/src/note.rs @@ -19,6 +19,7 @@ use result::Result; use error::NoteError as NE; use error::NoteErrorKind as NEK; +#[derive(Debug)] pub struct Note<'a> { entry: FileLockEntry<'a>, } @@ -32,7 +33,7 @@ impl<'a> Note<'a> { let fle = { let lockentry = store.create(ModuleEntryPath::new(name.clone()).into_storeid()); if lockentry.is_err() { - return Err(NE::new(NEK::StoreWriteError, Some(Box::new(lockentry.err().unwrap())))); + return Err(NE::new(NEK::StoreWriteError, Some(Box::new(lockentry.unwrap_err())))); } let mut lockentry = lockentry.unwrap(); @@ -44,13 +45,13 @@ impl<'a> Note<'a> { let setres = header.set("note", Value::Table(BTreeMap::new())); if setres.is_err() { let kind = NEK::StoreWriteError; - return Err(NE::new(kind, Some(Box::new(setres.err().unwrap())))); + return Err(NE::new(kind, Some(Box::new(setres.unwrap_err())))); } let setres = header.set("note.name", Value::String(name)); if setres.is_err() { let kind = NEK::StoreWriteError; - return Err(NE::new(kind, Some(Box::new(setres.err().unwrap())))); + return Err(NE::new(kind, Some(Box::new(setres.unwrap_err())))); } } @@ -171,6 +172,7 @@ impl<'a> Deref for Note<'a> { } +#[derive(Debug)] pub struct NoteIterator<'a> { store: &'a Store, iditer: StoreIdIterator, diff --git a/libimagrt/src/runtime.rs b/libimagrt/src/runtime.rs index b89bf5b4..7319958f 100644 --- a/libimagrt/src/runtime.rs +++ b/libimagrt/src/runtime.rs @@ -17,6 +17,7 @@ use logger::ImagLogger; use libimagstore::store::Store; +#[derive(Debug)] pub struct Runtime<'a> { rtp: PathBuf, configuration: Option, @@ -73,7 +74,7 @@ impl<'a> Runtime<'a> { let cfg = Configuration::new(&rtp); let cfg = if cfg.is_err() { - let e = cfg.err().unwrap(); + let e = cfg.unwrap_err(); if e.err_type() != ConfigErrorKind::NoConfigFileFound { let cause : Option> = Some(Box::new(e)); return Err(RuntimeError::new(RuntimeErrorKind::Instantiate, cause)); diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index 2801a230..9d174e24 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -156,7 +156,7 @@ impl Store { if c.is_err() { debug!("Failed"); return Err(StoreError::new(StoreErrorKind::StorePathCreate, - Some(Box::new(c.err().unwrap())))); + Some(Box::new(c.unwrap_err())))); } } else { if location.is_file() { @@ -537,6 +537,7 @@ impl Drop for Store { } /// A struct that allows you to borrow an Entry +#[derive(Debug)] pub struct FileLockEntry<'a> { store: &'a Store, entry: Entry, @@ -764,7 +765,7 @@ impl EntryHeader { pub fn set_with_sep(&mut self, spec: &str, sep: char, v: Value) -> Result> { let tokens = EntryHeader::tokenize(spec, sep); if tokens.is_err() { // return parser error if any - return Err(tokens.err().unwrap()); + return Err(tokens.unwrap_err()); } let tokens = tokens.unwrap(); debug!("tokens = {:?}", tokens); @@ -779,7 +780,7 @@ impl EntryHeader { let path_to_dest = tokens[..(tokens.len() - 1)].into(); // N - 1 tokens let value = EntryHeader::walk_header(&mut self.header, path_to_dest); // walk N-1 tokens if value.is_err() { - return Err(value.err().unwrap()); + return Err(value.unwrap_err()); } let mut value = value.unwrap(); debug!("walked value = {:?}", value); @@ -871,14 +872,14 @@ impl EntryHeader { pub fn read_with_sep(&self, spec: &str, splitchr: char) -> Result> { let tokens = EntryHeader::tokenize(spec, splitchr); if tokens.is_err() { // return parser error if any - return Err(tokens.err().unwrap()); + return Err(tokens.unwrap_err()); } let tokens = tokens.unwrap(); let mut header_clone = self.header.clone(); // we clone as READing is simpler this way let value = EntryHeader::walk_header(&mut header_clone, tokens); // walk N-1 tokens if value.is_err() { - let e = value.err().unwrap(); + let e = value.unwrap_err(); return match e.err_type() { // We cannot find the header key, as there is no path to it StoreErrorKind::HeaderKeyNotFound => Ok(None), @@ -891,7 +892,7 @@ impl EntryHeader { pub fn delete(&mut self, spec: &str) -> Result> { let tokens = EntryHeader::tokenize(spec, '.'); if tokens.is_err() { // return parser error if any - return Err(tokens.err().unwrap()); + return Err(tokens.unwrap_err()); } let tokens = tokens.unwrap(); @@ -905,7 +906,7 @@ impl EntryHeader { let path_to_dest = tokens[..(tokens.len() - 1)].into(); // N - 1 tokens let value = EntryHeader::walk_header(&mut self.header, path_to_dest); // walk N-1 tokens if value.is_err() { - return Err(value.err().unwrap()); + return Err(value.unwrap_err()); } let mut value = value.unwrap(); debug!("walked value = {:?}", value); diff --git a/libimagstore/src/storeid.rs b/libimagstore/src/storeid.rs index 35c3c0f8..7c5940c1 100644 --- a/libimagstore/src/storeid.rs +++ b/libimagstore/src/storeid.rs @@ -1,6 +1,9 @@ use std::path::PathBuf; use glob::Paths; use semver::Version; +use std::fmt::{Debug, Formatter}; +use std::fmt::Error as FmtError; +use std::result::Result as RResult; use error::{StoreError, StoreErrorKind}; use store::Result; @@ -94,6 +97,14 @@ pub struct StoreIdIterator { paths: Paths, } +impl Debug for StoreIdIterator { + + fn fmt(&self, fmt: &mut Formatter) -> RResult<(), FmtError> { + write!(fmt, "StoreIdIterator") + } + +} + impl StoreIdIterator { pub fn new(paths: Paths) -> StoreIdIterator {