imag-habit: 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 c1bc5d4bf6
commit 8fb35b5fe1
2 changed files with 8 additions and 5 deletions

View file

@ -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" }

View file

@ -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::<usize>()
.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);