From 5ed60f48cdf6a14efae9c06cd259f4c87ac2732c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 4 Sep 2016 17:18:05 +0200 Subject: [PATCH] Print errors (dbg) when import_task() failed --- libimagtodo/Cargo.toml | 3 +++ libimagtodo/src/lib.rs | 1 + libimagtodo/src/task.rs | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/libimagtodo/Cargo.toml b/libimagtodo/Cargo.toml index cc4d0c2f..28bef1a4 100644 --- a/libimagtodo/Cargo.toml +++ b/libimagtodo/Cargo.toml @@ -17,3 +17,6 @@ path = "../libimagstore" [dependencies.libimagerror] path = "../libimagerror" +[dependencies.libimagutil] +path = "../libimagutil" + diff --git a/libimagtodo/src/lib.rs b/libimagtodo/src/lib.rs index 3376ac62..171856f8 100644 --- a/libimagtodo/src/lib.rs +++ b/libimagtodo/src/lib.rs @@ -20,6 +20,7 @@ extern crate serde_json; #[macro_use] extern crate libimagstore; #[macro_use] extern crate libimagerror; +extern crate libimagutil; extern crate task_hookrs; module_entry_path_mod!("todo"); diff --git a/libimagtodo/src/task.rs b/libimagtodo/src/task.rs index 6b3dc990..16ba3167 100644 --- a/libimagtodo/src/task.rs +++ b/libimagtodo/src/task.rs @@ -11,6 +11,8 @@ use task_hookrs::import::{import_task, import_tasks}; use libimagstore::store::{FileLockEntry, Store}; use libimagstore::storeid::{IntoStoreId, StoreIdIterator, StoreId}; +use libimagerror::trace::MapErrTrace; +use libimagutil::debug_result::DebugResult; use module_path::ModuleEntryPath; use error::{TodoError, TodoErrorKind, MapErrInto}; @@ -32,6 +34,8 @@ impl<'a> Task<'a> { r.read_line(&mut line); import_task(&line.as_str()) .map_err_into(TodoErrorKind::ImportError) + .map_dbg_err_str("Error while importing task") + .map_err_dbg_trace() .and_then(|t| { let uuid = t.uuid().clone(); t.into_task(store).map(|t| (t, line, uuid)) @@ -61,6 +65,8 @@ impl<'a> Task<'a> { pub fn get_from_string(store: &'a Store, s: String) -> Result, String>> { import_task(s.as_str()) .map_err_into(TodoErrorKind::ImportError) + .map_dbg_err_str("Error while importing task") + .map_err_dbg_trace() .map(|t| t.uuid().clone()) .and_then(|uuid| Task::get_from_uuid(store, uuid)) .and_then(|o| match o { @@ -96,6 +102,8 @@ impl<'a> Task<'a> { Ok(task) => Ok(task), Err(string) => import_task(string.as_str()) .map_err_into(TodoErrorKind::ImportError) + .map_dbg_err_str("Error while importing task") + .map_err_dbg_trace() .and_then(|t| t.into_task(store)), }) }