diff options
Diffstat (limited to 'bin/domain/imag-calendar/src/util.rs')
-rw-r--r-- | bin/domain/imag-calendar/src/util.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/bin/domain/imag-calendar/src/util.rs b/bin/domain/imag-calendar/src/util.rs index 8dd382d9..1467d310 100644 --- a/bin/domain/imag-calendar/src/util.rs +++ b/bin/domain/imag-calendar/src/util.rs @@ -23,9 +23,10 @@ use clap::ArgMatches; use vobject::icalendar::ICalendar; use vobject::icalendar::Event; use handlebars::Handlebars; -use failure::Fallible as Result; -use failure::Error; -use failure::err_msg; +use anyhow::Result; +use anyhow::Error; +use failure::Fail; + use toml_query::read::TomlValueReadTypeExt; use chrono::NaiveDateTime; @@ -36,7 +37,6 @@ use libimagentryref::reference::fassade::RefFassade; use libimagentryref::reference::Ref; use libimagentryref::reference::Config; use libimagentryref::hasher::default::DefaultHasher; -use libimagerror::trace::MapErrTrace; use crate::libimagcalendar::store::EventStore; #[derive(Debug)] @@ -54,8 +54,8 @@ impl<'a> ParsedEventFLE<'a> { pub fn parse(fle: FileLockEntry<'a>, refconfig: &Config) -> Result<Self> { fle.as_ref_with_hasher::<DefaultHasher>() .get_path(refconfig) - .and_then(|p| ::std::fs::read_to_string(p).map_err(Error::from)) - .and_then(|s| ICalendar::build(&s).map_err(Error::from)) + .and_then(|p| ::std::fs::read_to_string(p).map_err(|e| Error::from(e.compat()))) + .and_then(|s| ICalendar::build(&s).map_err(|e| Error::from(e.compat()))) .map(|cal| ParsedEventFLE { inner: fle, data: cal, @@ -79,9 +79,9 @@ pub fn get_event_print_format(config_value_path: &'static str, rt: &Runtime, scm .map(Ok) .unwrap_or_else(|| { rt.config() - .ok_or_else(|| err_msg("No configuration file"))? + .ok_or_else(|| anyhow!("No configuration file"))? .read_string(config_value_path)? - .ok_or_else(|| err_msg("Configuration 'contact.list_format' does not exist")) + .ok_or_else(|| anyhow!("Configuration 'contact.list_format' does not exist")) }) .and_then(|fmt| { let mut hb = Handlebars::new(); @@ -124,19 +124,19 @@ pub fn build_data_object_for_handlebars<'a>(i: usize, event: &Event<'a>) } pub fn kairos_parse(spec: &str) -> Result<NaiveDateTime> { - match ::kairos::parser::parse(spec).map_err_trace_exit_unwrap() { + match ::kairos::parser::parse(spec).map_err(|e| Error::from(e.compat()))? { ::kairos::parser::Parsed::Iterator(_) => { trace!("before-filter spec resulted in iterator"); - Err(format_err!("Not a moment in time: {}", spec)) + Err(anyhow!("Not a moment in time: {}", spec)) } ::kairos::parser::Parsed::TimeType(tt) => { trace!("before-filter spec resulted in timetype"); tt.calculate() - .map_err_trace_exit_unwrap() + .map_err(|e| Error::from(e.compat()))? .get_moment() .cloned() - .ok_or_else(|| format_err!("Not a moment in time: {}", spec)) + .ok_or_else(|| anyhow!("Not a moment in time: {}", spec)) } } } @@ -151,7 +151,7 @@ pub fn find_event_by_id<'a>(store: &'a Store, id: &str, refconfig: &Config) -> R let sid = sid?; let event = store.get(sid.clone())?.ok_or_else(|| { - format_err!("Cannot get {}, which should be there.", sid) + anyhow!("Cannot get {}, which should be there.", sid) })?; trace!("Checking whether {} is represented by {}", id, event.get_location()); |