summaryrefslogtreecommitdiffstats
path: root/bin/domain/imag-todo
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-02-11 13:49:45 +0100
committerMatthias Beyer <mail@beyermatthias.de>2018-02-12 21:19:48 +0100
commit7892782675f7c0325d54c8644a2cbca0a81cce5d (patch)
tree2ce25473b06ff0ea6e26c9ddc300f93d17364679 /bin/domain/imag-todo
parent074f9826fd311536db0e7e7417f0cab404f86716 (diff)
Refactor error handling
Diffstat (limited to 'bin/domain/imag-todo')
-rw-r--r--bin/domain/imag-todo/src/main.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/bin/domain/imag-todo/src/main.rs b/bin/domain/imag-todo/src/main.rs
index ab9f1a3b..656899a0 100644
--- a/bin/domain/imag-todo/src/main.rs
+++ b/bin/domain/imag-todo/src/main.rs
@@ -33,7 +33,7 @@ use std::io::stdin;
use libimagrt::runtime::Runtime;
use libimagrt::setup::generate_runtime_setup;
use libimagtodo::taskstore::TaskStore;
-use libimagerror::trace::{MapErrTrace, trace_error, trace_error_exit};
+use libimagerror::trace::{MapErrTrace, trace_error};
mod ui;
@@ -62,10 +62,12 @@ fn tw_hook(rt: &Runtime) {
// implements BufRead which is required for `Store::import_task_from_reader()`
let stdin = stdin.lock();
- match rt.store().import_task_from_reader(stdin) {
- Ok((_, line, uuid)) => println!("{}\nTask {} stored in imag", line, uuid),
- Err(e) => trace_error_exit(&e, 1),
- }
+ let (_, line, uuid ) = rt
+ .store()
+ .import_task_from_reader(stdin)
+ .map_err_trace_exit_unwrap(1);
+
+ println!("{}\nTask {} stored in imag", line, uuid);
} 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.
@@ -126,8 +128,8 @@ fn list(rt: &Runtime) {
.args(&uuids)
.spawn()
.unwrap_or_else(|e| {
- trace_error(&e);
- panic!("Failed to execute `task` on the commandline. I'm dying now.");
+ error!("Failed to execute `task` on the commandline: {:?}. I'm dying now.", e);
+ ::std::process::exit(1)
})
.wait_with_output()
.unwrap_or_else(|e| panic!("failed to unwrap output: {}", e));