From 8fb35b5fe1c0a81a746892f4e4df01a51db74b9f Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 30 Oct 2018 18:40:53 +0100 Subject: [PATCH] imag-habit: Move from error-chain to failure Signed-off-by: Matthias Beyer --- bin/domain/imag-habit/Cargo.toml | 5 +++-- bin/domain/imag-habit/src/main.rs | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/domain/imag-habit/Cargo.toml b/bin/domain/imag-habit/Cargo.toml index 7aee14ae..b7018bfa 100644 --- a/bin/domain/imag-habit/Cargo.toml +++ b/bin/domain/imag-habit/Cargo.toml @@ -25,9 +25,10 @@ maintenance = { status = "actively-developed" } chrono = "0.4" log = "0.4" toml = "0.4" -toml-query = "0.7" -kairos = { git = "https://github.com/matthiasbeyer/kairos", branch = "master" } +toml-query = { git = "https://github.com/matthiasbeyer/toml-query", branch = "failure" } +kairos = { git = "https://github.com/matthiasbeyer/kairos", branch = "failure" } prettytable-rs = "0.8" +failure = "0.1" libimagerror = { version = "0.9.0", path = "../../../lib/core/libimagerror" } libimagstore = { version = "0.9.0", path = "../../../lib/core/libimagstore" } diff --git a/bin/domain/imag-habit/src/main.rs b/bin/domain/imag-habit/src/main.rs index 63246fd8..6f81e077 100644 --- a/bin/domain/imag-habit/src/main.rs +++ b/bin/domain/imag-habit/src/main.rs @@ -39,6 +39,7 @@ extern crate toml_query; extern crate kairos; extern crate chrono; extern crate prettytable; +#[macro_use] extern crate failure; extern crate libimaghabit; extern crate libimagstore; @@ -53,6 +54,7 @@ use std::process::exit; use prettytable::Table; use prettytable::Cell; use prettytable::Row; +use failure::Error; use libimagrt::runtime::Runtime; use libimagrt::setup::generate_runtime_setup; @@ -232,8 +234,7 @@ fn delete(rt: &Runtime) { // future flag. If it is true, the check will not be performed and it is assumed that `--future` // was passed. fn today(rt: &Runtime, future: bool) { - use libimaghabit::error::ResultExt; - use libimaghabit::error::HabitErrorKind as HEK; + use failure::ResultExt; let (future, show_done) = { if !future { @@ -296,7 +297,8 @@ fn today(rt: &Runtime, future: bool) { am.value_of("today-show-next-n") .map(|x| { x.parse::() - .chain_err(|| HEK::from(format!("Cannot parse String '{}' to integer", x))) + .context(format_err!("Cannot parse String '{}' to integer", x)) + .map_err(Error::from) .map_err_trace_exit_unwrap(1) }) }).unwrap_or(5);