diff --git a/bin/core/imag-annotate/Cargo.toml b/bin/core/imag-annotate/Cargo.toml index 6819ea29..25e79c57 100644 --- a/bin/core/imag-annotate/Cargo.toml +++ b/bin/core/imag-annotate/Cargo.toml @@ -26,6 +26,7 @@ log = "0.4.0" url = "1.2" toml = "0.4" toml-query = "0.7" +failure = "0.1" libimagstore = { version = "0.9.0", path = "../../../lib/core/libimagstore" } libimagrt = { version = "0.9.0", path = "../../../lib/core/libimagrt" } diff --git a/bin/core/imag-annotate/src/main.rs b/bin/core/imag-annotate/src/main.rs index ddeecf90..639488ea 100644 --- a/bin/core/imag-annotate/src/main.rs +++ b/bin/core/imag-annotate/src/main.rs @@ -35,6 +35,7 @@ extern crate clap; #[macro_use] extern crate log; +extern crate failure; extern crate libimagentryannotation; extern crate libimagentryedit; @@ -46,9 +47,11 @@ extern crate libimagutil; use std::io::Write; use std::path::PathBuf; +use failure::Error; +use failure::err_msg; + use libimagentryannotation::annotateable::*; use libimagentryannotation::annotation_fetcher::*; -use libimagentryannotation::error::AnnotationError as AE; use libimagentryedit::edit::*; use libimagerror::trace::MapErrTrace; use libimagerror::exit::ExitUnwrap; @@ -97,7 +100,7 @@ fn add(rt: &Runtime) { let _ = rt.store() .get(entry_name) .map_err_trace_exit_unwrap(1) - .ok_or(AE::from("Entry does not exist".to_owned())) + .ok_or_else(|| Error::from(err_msg("Entry does not exist".to_owned()))) .map_err_trace_exit_unwrap(1) .annotate(rt.store(), annotation_name) .map_err_trace_exit_unwrap(1) @@ -114,7 +117,7 @@ fn remove(rt: &Runtime) { let mut entry = rt.store() .get(PathBuf::from(entry_name).into_storeid().map_err_trace_exit_unwrap(1)) .map_err_trace_exit_unwrap(1) - .ok_or(AE::from("Entry does not exist".to_owned())) + .ok_or_else(|| Error::from(err_msg("Entry does not exist".to_owned()))) .map_err_trace_exit_unwrap(1); let annotation = entry @@ -148,7 +151,7 @@ fn list(rt: &Runtime) { .store() .get(pb.into_storeid().map_err_trace_exit_unwrap(1)) .map_err_trace_exit_unwrap(1) - .ok_or(AE::from("Entry does not exist".to_owned())) + .ok_or_else(|| Error::from(err_msg("Entry does not exist"))) .map_err_trace_exit_unwrap(1) .annotations(rt.store()) .map_err_trace_exit_unwrap(1)