diff options
Diffstat (limited to 'bin/domain/imag-timetrack/src')
-rw-r--r-- | bin/domain/imag-timetrack/src/day.rs | 8 | ||||
-rw-r--r-- | bin/domain/imag-timetrack/src/list.rs | 10 | ||||
-rw-r--r-- | bin/domain/imag-timetrack/src/main.rs | 1 | ||||
-rw-r--r-- | bin/domain/imag-timetrack/src/month.rs | 8 | ||||
-rw-r--r-- | bin/domain/imag-timetrack/src/start.rs | 4 | ||||
-rw-r--r-- | bin/domain/imag-timetrack/src/stop.rs | 4 | ||||
-rw-r--r-- | bin/domain/imag-timetrack/src/track.rs | 6 | ||||
-rw-r--r-- | bin/domain/imag-timetrack/src/week.rs | 8 | ||||
-rw-r--r-- | bin/domain/imag-timetrack/src/year.rs | 8 |
9 files changed, 31 insertions, 26 deletions
diff --git a/bin/domain/imag-timetrack/src/day.rs b/bin/domain/imag-timetrack/src/day.rs index 1e59a852..378b89dc 100644 --- a/bin/domain/imag-timetrack/src/day.rs +++ b/bin/domain/imag-timetrack/src/day.rs @@ -22,13 +22,13 @@ use std::str::FromStr; use filters::filter::Filter; use chrono::NaiveDateTime; +use failure::Error; use libimagerror::trace::trace_error; use libimagerror::trace::MapErrTrace; use libimagerror::iter::TraceIterator; use libimagerror::io::ToExitCode; use libimagstore::store::FileLockEntry; -use libimagtimetrack::error::TimeTrackError as TTE; use libimagtimetrack::timetrackingstore::TimeTrackStore; use libimagtimetrack::timetracking::TimeTracking; use libimagtimetrack::tag::TimeTrackingTag; @@ -44,7 +44,7 @@ pub fn day(rt: &Runtime) -> i32 { let filter = { let start = match cmd.value_of("start").map(NaiveDateTime::from_str) { None => ::chrono::offset::Local::today().and_hms(0, 0, 0).naive_local(), - Some(s) => match s.map_err(TTE::from) { + Some(s) => match s.map_err(Error::from) { Ok(dt) => dt, Err(e) => { trace_error(&e); @@ -55,7 +55,7 @@ pub fn day(rt: &Runtime) -> i32 { let end = match cmd.value_of("end").map(NaiveDateTime::from_str) { None => ::chrono::offset::Local::today().and_hms(23, 59, 59).naive_local(), - Some(s) => match s.map_err(TTE::from) { + Some(s) => match s.map_err(Error::from) { Ok(dt) => dt, Err(e) => { trace_error(&e); @@ -91,7 +91,7 @@ pub fn day(rt: &Runtime) -> i32 { .map_err_trace_exit_unwrap(1) .trace_unwrap() .filter(|e| filter.filter(e)) - .map(|e| -> Result<_, TTE> { + .map(|e| -> Result<_, Error> { debug!("Processing {:?}", e.get_location()); let tag = e.get_timetrack_tag()?; diff --git a/bin/domain/imag-timetrack/src/list.rs b/bin/domain/imag-timetrack/src/list.rs index b6366196..13de6412 100644 --- a/bin/domain/imag-timetrack/src/list.rs +++ b/bin/domain/imag-timetrack/src/list.rs @@ -25,15 +25,17 @@ use prettytable::Cell; use kairos::parser::Parsed; use kairos::parser::parse as kairos_parse; use clap::ArgMatches; +use failure::Fallible as Result; +use failure::ResultExt; +use failure::err_msg; +use failure::Error; use libimagerror::trace::trace_error; use libimagerror::trace::MapErrTrace; use libimagerror::iter::TraceIterator; use libimagstore::store::FileLockEntry; -use libimagtimetrack::error::TimeTrackError; use libimagtimetrack::timetrackingstore::TimeTrackStore; use libimagtimetrack::timetracking::TimeTracking; -use libimagtimetrack::error::Result; use libimagrt::runtime::Runtime; @@ -63,6 +65,7 @@ pub fn list(rt: &Runtime) -> i32 { ::std::process::exit(1) }, Some(Err(e)) => { + let e = Error::from(e); trace_error(&e); ::std::process::exit(1) } @@ -164,7 +167,8 @@ pub fn list_impl(rt: &Runtime, }) .map_err_trace_exit_unwrap(1) .print(&mut rt.stdout()) - .map_err(|_| TimeTrackError::from(String::from("Failed printing table"))) + .context(err_msg("Failed to print table")) + .map_err(Error::from) .map(|_| 0) .map_err_trace() .unwrap_or(1) diff --git a/bin/domain/imag-timetrack/src/main.rs b/bin/domain/imag-timetrack/src/main.rs index d482d112..a17cd26c 100644 --- a/bin/domain/imag-timetrack/src/main.rs +++ b/bin/domain/imag-timetrack/src/main.rs @@ -41,6 +41,7 @@ extern crate filters; extern crate itertools; extern crate prettytable; extern crate kairos; +extern crate failure; extern crate libimagerror; extern crate libimagstore; diff --git a/bin/domain/imag-timetrack/src/month.rs b/bin/domain/imag-timetrack/src/month.rs index 39ac1735..7a65f64f 100644 --- a/bin/domain/imag-timetrack/src/month.rs +++ b/bin/domain/imag-timetrack/src/month.rs @@ -22,13 +22,13 @@ use std::str::FromStr; use filters::filter::Filter; use chrono::NaiveDateTime; +use failure::Error; use libimagerror::trace::trace_error; use libimagerror::trace::MapErrTrace; use libimagerror::io::ToExitCode; use libimagerror::iter::TraceIterator; use libimagstore::store::FileLockEntry; -use libimagtimetrack::error::TimeTrackError as TTE; use libimagtimetrack::timetrackingstore::TimeTrackStore; use libimagtimetrack::timetracking::TimeTracking; use libimagtimetrack::tag::TimeTrackingTag; @@ -48,7 +48,7 @@ pub fn month(rt: &Runtime) -> i32 { let start = match cmd.value_of("start").map(::chrono::naive::NaiveDateTime::from_str) { None => NaiveDate::from_ymd(now.year(), now.month(), 1).and_hms(0, 0, 0), - Some(s) => match s.map_err(TTE::from) { + Some(s) => match s.map_err(Error::from) { Ok(dt) => dt, Err(e) => { trace_error(&e); @@ -70,7 +70,7 @@ pub fn month(rt: &Runtime) -> i32 { NaiveDate::from_ymd(year, month, 1).and_hms(0, 0, 0) }, - Some(s) => match s.map_err(TTE::from) { + Some(s) => match s.map_err(Error::from) { Ok(dt) => dt, Err(e) => { trace_error(&e); @@ -106,7 +106,7 @@ pub fn month(rt: &Runtime) -> i32 { .map_err_trace_exit_unwrap(1) .trace_unwrap() .filter(|e| filter.filter(e)) - .map(|e| -> Result<_, TTE> { + .map(|e| -> Result<_, Error> { debug!("Processing {:?}", e.get_location()); let tag = e.get_timetrack_tag()?; diff --git a/bin/domain/imag-timetrack/src/start.rs b/bin/domain/imag-timetrack/src/start.rs index 6827bb30..abf18b93 100644 --- a/bin/domain/imag-timetrack/src/start.rs +++ b/bin/domain/imag-timetrack/src/start.rs @@ -20,10 +20,10 @@ use std::str::FromStr; use chrono::naive::NaiveDateTime; +use failure::Error; use libimagrt::runtime::Runtime; use libimagerror::trace::trace_error; -use libimagtimetrack::error::TimeTrackError as TTE; use libimagtimetrack::tag::TimeTrackingTag; use libimagtimetrack::timetrackingstore::TimeTrackStore; use libimagerror::trace::MapErrTrace; @@ -34,7 +34,7 @@ pub fn start(rt: &Runtime) -> i32 { let start = match cmd.value_of("start-time") { None | Some("now") => ::chrono::offset::Local::now().naive_local(), - Some(ndt) => match NaiveDateTime::from_str(ndt).map_err(TTE::from) { + Some(ndt) => match NaiveDateTime::from_str(ndt).map_err(Error::from) { Ok(ndt) => ndt, Err(e) => { trace_error(&e); diff --git a/bin/domain/imag-timetrack/src/stop.rs b/bin/domain/imag-timetrack/src/stop.rs index c4099b52..539c80a4 100644 --- a/bin/domain/imag-timetrack/src/stop.rs +++ b/bin/domain/imag-timetrack/src/stop.rs @@ -21,13 +21,13 @@ use std::str::FromStr; use filters::filter::Filter; use chrono::NaiveDateTime; +use failure::Error; use libimagerror::trace::trace_error; use libimagerror::iter::TraceIterator; use libimagerror::trace::MapErrTrace; use libimagrt::runtime::Runtime; -use libimagtimetrack::error::TimeTrackError as TTE; use libimagtimetrack::timetracking::TimeTracking; use libimagtimetrack::tag::TimeTrackingTag; use libimagtimetrack::timetrackingstore::*; @@ -42,7 +42,7 @@ pub fn stop(rt: &Runtime) -> i32 { let stop_time = match cmd.value_of("stop-time") { None | Some("now") => ::chrono::offset::Local::now().naive_local(), - Some(ndt) => match NaiveDateTime::from_str(ndt).map_err(TTE::from) { + Some(ndt) => match NaiveDateTime::from_str(ndt).map_err(Error::from) { Ok(ndt) => ndt, Err(e) => { trace_error(&e); diff --git a/bin/domain/imag-timetrack/src/track.rs b/bin/domain/imag-timetrack/src/track.rs index ffc9020f..0e709615 100644 --- a/bin/domain/imag-timetrack/src/track.rs +++ b/bin/domain/imag-timetrack/src/track.rs @@ -22,10 +22,10 @@ use std::process::exit; use clap::ArgMatches; use chrono::naive::NaiveDate; use chrono::naive::NaiveDateTime; +use failure::Error; use libimagrt::runtime::Runtime; use libimagerror::trace::trace_error; -use libimagtimetrack::error::TimeTrackError as TTE; use libimagtimetrack::tag::TimeTrackingTag; use libimagtimetrack::timetrackingstore::TimeTrackStore; use libimagerror::trace::MapErrTrace; @@ -43,10 +43,10 @@ pub fn track(rt: &Runtime) -> i32 { match cmd.value_of(clap_name) { Some("now") => Some(::chrono::offset::Local::now().naive_local()), Some(els) => { - match NaiveDateTime::parse_from_str(els, DATE_TIME_PARSE_FMT).map_err(TTE::from) { + match NaiveDateTime::parse_from_str(els, DATE_TIME_PARSE_FMT).map_err(Error::from) { Ok(ndt) => Some(ndt), Err(e_ndt) => { - match NaiveDate::parse_from_str(els, DATE_PARSE_FMT).map_err(TTE::from) { + match NaiveDate::parse_from_str(els, DATE_PARSE_FMT).map_err(Error::from) { Ok(ndt) => Some(ndt.and_hms(0, 0, 0)), Err(e_nd) => { error!("Cannot parse date {}:", errname); diff --git a/bin/domain/imag-timetrack/src/week.rs b/bin/domain/imag-timetrack/src/week.rs index 90da88b6..c8a74520 100644 --- a/bin/domain/imag-timetrack/src/week.rs +++ b/bin/domain/imag-timetrack/src/week.rs @@ -22,13 +22,13 @@ use std::str::FromStr; use filters::filter::Filter; use chrono::NaiveDateTime; +use failure::Error; use libimagerror::trace::trace_error; use libimagerror::trace::MapErrTrace; use libimagerror::iter::TraceIterator; use libimagerror::io::ToExitCode; use libimagstore::store::FileLockEntry; -use libimagtimetrack::error::TimeTrackError as TTE; use libimagtimetrack::timetrackingstore::TimeTrackStore; use libimagtimetrack::timetracking::TimeTracking; use libimagtimetrack::tag::TimeTrackingTag; @@ -50,7 +50,7 @@ pub fn week(rt: &Runtime) -> i32 { let start = match cmd .value_of("start") .map(|s| { - ::chrono::naive::NaiveDateTime::from_str(s).map_err(TTE::from) + ::chrono::naive::NaiveDateTime::from_str(s).map_err(Error::from) }) { None => NaiveDate::from_isoywd(this_week.year(), this_week.week(), Weekday::Mon) @@ -65,7 +65,7 @@ pub fn week(rt: &Runtime) -> i32 { let end = match cmd .value_of("end") .map(|s| { - ::chrono::naive::NaiveDateTime::from_str(s).map_err(TTE::from) + ::chrono::naive::NaiveDateTime::from_str(s).map_err(Error::from) }) { None => NaiveDate::from_isoywd(this_week.year(), this_week.week(), Weekday::Sun) @@ -104,7 +104,7 @@ pub fn week(rt: &Runtime) -> i32 { .map_err_trace_exit_unwrap(1) .trace_unwrap() .filter(|e| filter.filter(e)) - .map(|e| -> Result<_, TTE> { + .map(|e| -> Result<_, Error> { debug!("Processing {:?}", e.get_location()); let tag = e.get_timetrack_tag()?; diff --git a/bin/domain/imag-timetrack/src/year.rs b/bin/domain/imag-timetrack/src/year.rs index 7904c6d3..2d5c70f1 100644 --- a/bin/domain/imag-timetrack/src/year.rs +++ b/bin/domain/imag-timetrack/src/year.rs @@ -22,13 +22,13 @@ use std::str::FromStr; use filters::filter::Filter; use chrono::NaiveDateTime; +use failure::Error; use libimagerror::trace::trace_error; use libimagerror::trace::MapErrTrace; use libimagerror::iter::TraceIterator; use libimagerror::io::ToExitCode; use libimagstore::store::FileLockEntry; -use libimagtimetrack::error::TimeTrackError as TTE; use libimagtimetrack::timetrackingstore::TimeTrackStore; use libimagtimetrack::timetracking::TimeTracking; use libimagtimetrack::tag::TimeTrackingTag; @@ -49,7 +49,7 @@ pub fn year(rt: &Runtime) -> i32 { let start = match cmd .value_of("start") .map(|s| { - ::chrono::naive::NaiveDateTime::from_str(s).map_err(TTE::from) + ::chrono::naive::NaiveDateTime::from_str(s).map_err(Error::from) }) { None => NaiveDate::from_ymd(now.year(), 1, 1).and_hms(0, 0, 0), @@ -63,7 +63,7 @@ pub fn year(rt: &Runtime) -> i32 { let end = match cmd .value_of("end") .map(|s| { - ::chrono::naive::NaiveDateTime::from_str(s).map_err(TTE::from) + ::chrono::naive::NaiveDateTime::from_str(s).map_err(Error::from) }) { None => { @@ -104,7 +104,7 @@ pub fn year(rt: &Runtime) -> i32 { .map_err_trace_exit_unwrap(1) .trace_unwrap() .filter(|e| filter.filter(e)) - .map(|e| -> Result<_, TTE> { + .map(|e| -> Result<_, Error> { debug!("Processing {:?}", e.get_location()); let tag = e.get_timetrack_tag()?; |