From b9a9fd52c4f529b17a5812e41776e2e8fe4f4744 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 6 Sep 2016 11:13:08 +0200 Subject: imag-todo: Use Err/Ok utils to map --- imag-todo/src/main.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/imag-todo/src/main.rs b/imag-todo/src/main.rs index 1163fe3c..a5ca650e 100644 --- a/imag-todo/src/main.rs +++ b/imag-todo/src/main.rs @@ -13,7 +13,6 @@ extern crate libimagstore; extern crate libimagerror; extern crate libimagtodo; -use std::process::exit; use std::process::{Command, Stdio}; use std::io::stdin; @@ -22,7 +21,7 @@ use toml::Value; use libimagrt::runtime::Runtime; use libimagrt::setup::generate_runtime_setup; use libimagtodo::task::Task; -use libimagerror::trace::trace_error; +use libimagerror::trace::{MapErrTrace, trace_error, trace_error_exit}; mod ui; @@ -51,18 +50,13 @@ fn tw_hook(rt: &Runtime) { match Task::import(rt.store(), stdin) { Ok((_, line, uuid)) => println!("{}\nTask {} stored in imag", line, uuid), - Err(e) => { - trace_error(&e); - exit(1); - } + Err(e) => trace_error_exit(&e, 1), } } else if subcmd.is_present("delete") { // The used hook is "on-modify". This hook gives two json-objects // per usage und wants one (the second one) back. let stdin = stdin(); - Task::delete_by_imports(rt.store(), stdin.lock()) - .map_err(|e| trace_error(&e)) - .ok(); + Task::delete_by_imports(rt.store(), stdin.lock()).map_err_trace().ok(); } else { // Should not be possible, as one argument is required via // ArgGroup @@ -120,8 +114,6 @@ fn list(rt: &Runtime) { println!("{}", outstring); }); - if let Err(e) = res { - trace_error(&e); - } + res.map_err_trace().ok(); } -- cgit v1.2.3