imag-annotate: Move from error-chain to failure

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2018-10-30 18:40:53 +01:00
parent 6d8bac314c
commit 11abf55a0f
2 changed files with 8 additions and 4 deletions

View file

@ -26,6 +26,7 @@ log = "0.4.0"
url = "1.2" url = "1.2"
toml = "0.4" toml = "0.4"
toml-query = "0.7" toml-query = "0.7"
failure = "0.1"
libimagstore = { version = "0.9.0", path = "../../../lib/core/libimagstore" } libimagstore = { version = "0.9.0", path = "../../../lib/core/libimagstore" }
libimagrt = { version = "0.9.0", path = "../../../lib/core/libimagrt" } libimagrt = { version = "0.9.0", path = "../../../lib/core/libimagrt" }

View file

@ -35,6 +35,7 @@
extern crate clap; extern crate clap;
#[macro_use] #[macro_use]
extern crate log; extern crate log;
extern crate failure;
extern crate libimagentryannotation; extern crate libimagentryannotation;
extern crate libimagentryedit; extern crate libimagentryedit;
@ -46,9 +47,11 @@ extern crate libimagutil;
use std::io::Write; use std::io::Write;
use std::path::PathBuf; use std::path::PathBuf;
use failure::Error;
use failure::err_msg;
use libimagentryannotation::annotateable::*; use libimagentryannotation::annotateable::*;
use libimagentryannotation::annotation_fetcher::*; use libimagentryannotation::annotation_fetcher::*;
use libimagentryannotation::error::AnnotationError as AE;
use libimagentryedit::edit::*; use libimagentryedit::edit::*;
use libimagerror::trace::MapErrTrace; use libimagerror::trace::MapErrTrace;
use libimagerror::exit::ExitUnwrap; use libimagerror::exit::ExitUnwrap;
@ -97,7 +100,7 @@ fn add(rt: &Runtime) {
let _ = rt.store() let _ = rt.store()
.get(entry_name) .get(entry_name)
.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) .map_err_trace_exit_unwrap(1)
.annotate(rt.store(), annotation_name) .annotate(rt.store(), annotation_name)
.map_err_trace_exit_unwrap(1) .map_err_trace_exit_unwrap(1)
@ -114,7 +117,7 @@ fn remove(rt: &Runtime) {
let mut entry = rt.store() let mut entry = rt.store()
.get(PathBuf::from(entry_name).into_storeid().map_err_trace_exit_unwrap(1)) .get(PathBuf::from(entry_name).into_storeid().map_err_trace_exit_unwrap(1))
.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); .map_err_trace_exit_unwrap(1);
let annotation = entry let annotation = entry
@ -148,7 +151,7 @@ fn list(rt: &Runtime) {
.store() .store()
.get(pb.into_storeid().map_err_trace_exit_unwrap(1)) .get(pb.into_storeid().map_err_trace_exit_unwrap(1))
.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) .map_err_trace_exit_unwrap(1)
.annotations(rt.store()) .annotations(rt.store())
.map_err_trace_exit_unwrap(1) .map_err_trace_exit_unwrap(1)