~matthiasbeyer/imag

43b9f6a0f39eced0eb59aca9008d859bc6e14449 — Matthias Beyer 1 year, 4 months ago 8ffb06c
Replace map_dbg() and map_dbg_str() with context() and inspect() calls

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
M bin/domain/imag-diary/Cargo.toml => bin/domain/imag-diary/Cargo.toml +1 -0
@@ 27,6 27,7 @@ toml-query = "0.9.2"
itertools = "0.8.0"
failure = "0.1.5"
resiter = "0.4.0"
option-inspect = "0.1.0"

libimagerror       = { version = "0.10.0", path = "../../../lib/core/libimagerror" }
libimagstore       = { version = "0.10.0", path = "../../../lib/core/libimagstore" }

M bin/domain/imag-diary/src/create.rs => bin/domain/imag-diary/src/create.rs +4 -3
@@ 25,6 25,7 @@ use failure::Error;
use failure::ResultExt;
use failure::err_msg;
use failure::Fallible as Result;
use option_inspect::*;

use libimagdiary::diary::Diary;
use libimagentryedit::edit::Edit;


@@ 103,7 104,7 @@ fn create_id_from_clispec(create: &ArgMatches, timed_type: Timed) -> Result<Naiv
        Timed::Minutely => {
            let min = create
                .value_of("minute")
                .map_dbg(|m| format!("minute = {:?}", m))
                .inspect(|m| debug!("minute = {:?}", m))
                .map(|s| {
                    FromStr::from_str(s)
                        .map_err(Error::from)


@@ 123,7 124,7 @@ fn create_id_from_clispec(create: &ArgMatches, timed_type: Timed) -> Result<Naiv
        Timed::Secondly => {
            let min = create
                .value_of("minute")
                .map_dbg(|m| format!("minute = {:?}", m))
                .inspect(|m| debug!("minute = {:?}", m))
                .map(|s| {
                    FromStr::from_str(s)
                        .map_err(Error::from)


@@ 135,7 136,7 @@ fn create_id_from_clispec(create: &ArgMatches, timed_type: Timed) -> Result<Naiv

            let sec = create
                .value_of("second")
                .map_dbg(|s| format!("second = {:?}", s))
                .inspect(|s| debug!("second = {:?}", s))
                .map(|s| {
                    FromStr::from_str(s)
                        .map_err(Error::from)

M bin/domain/imag-diary/src/lib.rs => bin/domain/imag-diary/src/lib.rs +1 -0
@@ 42,6 42,7 @@ extern crate chrono;
extern crate toml;
extern crate toml_query;
extern crate itertools;
extern crate option_inspect;

extern crate libimagdiary;
extern crate libimagentryedit;

M bin/domain/imag-diary/src/list.rs => bin/domain/imag-diary/src/list.rs +1 -3
@@ 26,7 26,6 @@ use resiter::AndThen;

use libimagdiary::diary::Diary;
use libimagrt::runtime::Runtime;
use libimagutil::debug_result::*;
use libimagdiary::diaryid::DiaryId;
use libimagdiary::diaryid::FromStoreId;
use libimagstore::storeid::IntoStoreId;


@@ 37,8 36,7 @@ pub fn list(rt: &Runtime) -> Result<()> {
    let diaryname = get_diary_name(rt)
        .ok_or_else(|| err_msg("No diary selected. Use either the configuration file or the commandline option"))?;

    let mut ids = Diary::entries(rt.store(), &diaryname)
        .map_dbg_str("Ok")?
    let mut ids = Diary::entries(rt.store(), &diaryname)?
        .and_then_ok(|id| DiaryId::from_storeid(&id))
        .collect::<Result<Vec<_>>>()?;


M bin/domain/imag-habit/Cargo.toml => bin/domain/imag-habit/Cargo.toml +1 -0
@@ 28,6 28,7 @@ kairos = "0.3.0"
prettytable-rs = "0.8.0"
failure = "0.1.5"
resiter = "0.4.0"
result-inspect = "0.1"

libimagerror       = { version = "0.10.0", path = "../../../lib/core/libimagerror" }
libimagstore       = { version = "0.10.0", path = "../../../lib/core/libimagstore" }

M bin/domain/imag-habit/src/lib.rs => bin/domain/imag-habit/src/lib.rs +3 -1
@@ 43,6 43,7 @@ extern crate resiter;
extern crate chrono;
extern crate prettytable;
#[macro_use] extern crate failure;
extern crate result_inspect;

extern crate libimaghabit;
extern crate libimagstore;


@@ 65,6 66,7 @@ use resiter::Filter;
use resiter::IterInnerOkOrElse;
use clap::App;
use chrono::NaiveDate;
use result_inspect::*;

use libimagrt::runtime::Runtime;
use libimagrt::application::ImagApplication;


@@ 133,7 135,7 @@ fn create(rt: &Runtime) -> Result<()> {

    let parsedate = |d, pname| match kairos_parse(d)? {
        Parsed::TimeType(tt) => tt.calculate()
            .map_dbg(|y| format!("TimeType yielded: '{:?}'", y))?
            .inspect(|y| debug!("TimeType yielded: '{:?}'", y))?
            .get_moment()
            .ok_or_else(|| {
                format_err!("Error: '{}' parameter does not yield a point in time", pname)

M lib/core/libimagrt/src/runtime.rs => lib/core/libimagrt/src/runtime.rs +1 -1
@@ 384,8 384,8 @@ impl<'a> Runtime<'a> {
            })
            .or_else(|_| env::var("EDITOR"))
            .map_err(|_| Error::from(EM::IO))
            .map_dbg(|s| format!("Editing with '{}'", s))
            .and_then(|s| {
                debug!("Editing with '{}'", s);
                let mut split = s.split_whitespace();
                let command   = split.next();
                if command.is_none() {

M lib/domain/libimaghabit/src/habit.rs => lib/domain/libimaghabit/src/habit.rs +6 -9
@@ 321,17 321,14 @@ pub mod builder {
                format_err!("Habit builder missing: {}", s)
            }

            let name = self.name
                .ok_or_else(|| mkerr("name"))
                .map_dbg_str("Success: Name present")?;
            let name = self.name.ok_or_else(|| mkerr("name"))?;
            debug!("Success: Name present");

            let dateobj = self.basedate
                .ok_or_else(|| mkerr("date"))
                .map_dbg_str("Success: Date present")?;
            let dateobj = self.basedate.ok_or_else(|| mkerr("date"))?;
            debug!("Success: Date present");

            let recur : String = self.recurspec
                .ok_or_else(|| mkerr("recurspec"))
                .map_dbg_str("Success: Recurr spec present")?;
            let recur : String = self.recurspec.ok_or_else(|| mkerr("recurspec"))?;
            debug!("Success: Recurr spec present");

            if let Some(until) = self.untildate {
                debug!("Success: Until-Date present");

M lib/entry/libimagentrylink/src/storecheck.rs => lib/entry/libimagentrylink/src/storecheck.rs +13 -23
@@ 145,29 145,19 @@ impl StoreLinkConsistentExt for Store {
                Ok(())
            };

        aggregate_link_network(&self)
            .map_dbg_str("Aggregated")
            .map_dbg(|nw| {
                let mut s = String::new();
                for (k, v) in nw {
                    s.push_str(&format!("{}\n in: {:?}\n out: {:?}", k, v.incoming, v.outgoing));
                }
                s
            })
            .and_then(|nw| {
                all_collected_storeids_exist(&nw)
                    .map(|_| nw)
                    .context(err_msg("Link handling error"))
                    .map_err(Error::from)
            })
            .and_then(|nw| {
                for (id, linking) in nw.iter() {
                    incoming_links_exists_as_outgoing_links(id, linking, &nw)?;
                    outgoing_links_exist_as_incoming_links(id, linking, &nw)?;
                }
                Ok(())
            })
            .map(|_| ())
        let nw = aggregate_link_network(&self)?;

        for (k, v) in nw.iter() {
            debug!("{}\n in: {:?}\n out: {:?}", k, v.incoming, v.outgoing);
        }

        all_collected_storeids_exist(&nw).context("Link handling error")?;

        for (id, linking) in nw.iter() {
            incoming_links_exists_as_outgoing_links(id, linking, &nw)?;
            outgoing_links_exist_as_incoming_links(id, linking, &nw)?;
        }
        Ok(())
    }
}


M lib/entry/libimagentryurl/src/iter.rs => lib/entry/libimagentryurl/src/iter.rs +1 -1
@@ 178,7 178,7 @@ impl<'a> Iterator for UrlIter<'a> {
                            debug!("Store::retrieve({:?}) succeeded", id);
                            debug!("getting uri link from file now");
                            f.get_url()
                                .map_dbg_str("Error happened while getting link URI from FLE")
                                .context("Error happened while getting link URI from FLE")
                                .with_context(|e| format!("URL -> Err = {:?}", e))
                                .map_err(Error::from)
                        })