diff --git a/imag-bookmark/src/main.rs b/imag-bookmark/src/main.rs index 2d003463..06490c24 100644 --- a/imag-bookmark/src/main.rs +++ b/imag-bookmark/src/main.rs @@ -17,7 +17,7 @@ use libimagrt::runtime::Runtime; use libimagrt::setup::generate_runtime_setup; use libimagbookmark::collection::BookmarkCollection; use libimagbookmark::link::Link as BookmarkLink; -use libimagerror::trace::trace_error; +use libimagerror::trace::{trace_error, trace_error_exit}; mod ui; @@ -96,10 +96,7 @@ fn list(rt: &Runtime) { }; debug!("... ready with listing"); }, - Err(e) => { - trace_error(&e); - exit(1); - }, + Err(e) => trace_error_exit(&e, 1), } }); info!("Ready"); diff --git a/imag-counter/src/create.rs b/imag-counter/src/create.rs index 22a38b34..a86f0c0a 100644 --- a/imag-counter/src/create.rs +++ b/imag-counter/src/create.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use std::process::exit; use libimagrt::runtime::Runtime; -use libimagerror::trace::trace_error; +use libimagerror::trace::trace_error_exit; use libimagcounter::counter::Counter; pub fn create(rt: &Runtime) { @@ -20,8 +20,7 @@ pub fn create(rt: &Runtime) { match Counter::new(rt.store(), String::from(name), init) { Err(e) => { warn!("Could not create Counter '{}' with initial value '{}'", name, init); - trace_error(&e); - exit(1); + trace_error_exit(&e, 1); }, Ok(_) => info!("Created Counter '{}' with initial value '{}'", name, init), } diff --git a/imag-counter/src/delete.rs b/imag-counter/src/delete.rs index 4d7e6067..c8b782ef 100644 --- a/imag-counter/src/delete.rs +++ b/imag-counter/src/delete.rs @@ -1,7 +1,7 @@ use std::process::exit; use libimagrt::runtime::Runtime; -use libimagerror::trace::trace_error; +use libimagerror::trace::trace_error_exit; use libimagcounter::counter::Counter; pub fn delete(rt: &Runtime) { @@ -13,8 +13,7 @@ pub fn delete(rt: &Runtime) { let name = String::from(scmd.value_of("name").unwrap()); // safe because clap enforces if let Err(e) = Counter::delete(name, rt.store()) { - trace_error(&e); - exit(1); + trace_error_exit(&e, 1); } info!("Ok"); diff --git a/imag-counter/src/interactive.rs b/imag-counter/src/interactive.rs index e07d8e1d..4dbb810d 100644 --- a/imag-counter/src/interactive.rs +++ b/imag-counter/src/interactive.rs @@ -10,7 +10,7 @@ use libimagcounter::counter::Counter; use libimagcounter::error::CounterError; use libimagrt::runtime::Runtime; use libimagutil::key_value_split::IntoKeyValue; -use libimagerror::trace::trace_error; +use libimagerror::trace::{trace_error, trace_error_exit}; type Result = RResult; @@ -47,8 +47,7 @@ pub fn interactive(rt: &Runtime) { let mut input = String::new(); if let Err(e) = stdin().read_line(&mut input) { - trace_error(&e); - exit(1); + trace_error_exit(&e, 1); } let cont = if !input.is_empty() { diff --git a/imag-counter/src/main.rs b/imag-counter/src/main.rs index 76dcc00c..304bbb5e 100644 --- a/imag-counter/src/main.rs +++ b/imag-counter/src/main.rs @@ -27,7 +27,7 @@ use std::str::FromStr; use libimagrt::setup::generate_runtime_setup; use libimagcounter::counter::Counter; -use libimagerror::trace::trace_error; +use libimagerror::trace::{trace_error, trace_error_exit}; use libimagutil::key_value_split::IntoKeyValue; mod create; @@ -75,7 +75,7 @@ fn main() { Counter::load(String::from(name), rt.store()) .map(|mut counter| { match counter.inc() { - Err(e) => { trace_error(&e); exit(1); }, + Err(e) => trace_error_exit(&e, 1), Ok(_) => info!("Ok"), } }) @@ -84,7 +84,7 @@ fn main() { Counter::load(String::from(name), rt.store()) .map(|mut counter| { match counter.dec() { - Err(e) => { trace_error(&e); exit(1); }, + Err(e) => trace_error_exit(&e, 1), Ok(_) => info!("Ok"), } }) @@ -93,7 +93,7 @@ fn main() { Counter::load(String::from(name), rt.store()) .map(|mut counter| { match counter.reset() { - Err(e) => { trace_error(&e); exit(1); }, + Err(e) => trace_error_exit(&e, 1), Ok(_) => info!("Ok"), } }) @@ -114,7 +114,7 @@ fn main() { Counter::load(String::from(key), rt.store()) .map(|mut counter| { match counter.set(value) { - Err(e) => { trace_error(&e); exit(1); }, + Err(e) => trace_error_exit(&e, 1), Ok(_) => info!("Ok"), } }) diff --git a/imag-diary/src/delete.rs b/imag-diary/src/delete.rs index 26e59900..271d08a0 100644 --- a/imag-diary/src/delete.rs +++ b/imag-diary/src/delete.rs @@ -4,7 +4,7 @@ use chrono::naive::datetime::NaiveDateTime; use libimagdiary::diary::Diary; use libimagdiary::diaryid::DiaryId; use libimagrt::runtime::Runtime; -use libimagerror::trace::trace_error; +use libimagerror::trace::trace_error_exit; use libimagtimeui::datetime::DateTime; use libimagtimeui::parse::Parse; @@ -40,10 +40,7 @@ pub fn delete(rt: &Runtime) { let to_del = match to_del { Some(Ok(e)) => e, - Some(Err(e)) => { - trace_error(&e); - exit(1); - }, + Some(Err(e)) => trace_error_exit(&e, 1), None => { warn!("No entry"); exit(1); @@ -57,10 +54,7 @@ pub fn delete(rt: &Runtime) { match diary.delete_entry(to_del) { Ok(_) => info!("Ok"), - Err(e) => { - trace_error(&e); - exit(1); - }, + Err(e) => trace_error_exit(&e, 1), } } diff --git a/imag-diary/src/view.rs b/imag-diary/src/view.rs index fd6e931c..0d0f5317 100644 --- a/imag-diary/src/view.rs +++ b/imag-diary/src/view.rs @@ -28,9 +28,7 @@ pub fn view(rt: &Runtime) { println!("\n---\n"); } }, - Err(e) => { - trace_error(&e); - }, + Err(e) => trace_error(&e), } } diff --git a/imag-link/src/main.rs b/imag-link/src/main.rs index 4341b40e..c1448678 100644 --- a/imag-link/src/main.rs +++ b/imag-link/src/main.rs @@ -34,7 +34,7 @@ use libimagstore::error::StoreError; use libimagstore::store::Entry; use libimagstore::store::FileLockEntry; use libimagstore::store::Store; -use libimagerror::trace::trace_error; +use libimagerror::trace::{trace_error, trace_error_exit}; use libimagentrylink::external::ExternalLinker; use clap::ArgMatches; use url::Url; @@ -117,8 +117,7 @@ fn handle_internal_linking(rt: &Runtime) { Some("add") => { for mut to_entry in to { if let Err(e) = to_entry.add_internal_link(&mut from) { - trace_error(&e); - exit(1); + trace_error_exit(&e, 1); } } }, @@ -126,8 +125,7 @@ fn handle_internal_linking(rt: &Runtime) { Some("remove") => { for mut to_entry in to { if let Err(e) = to_entry.remove_internal_link(&mut from) { - trace_error(&e); - exit(1); + trace_error_exit(&e, 1); } } }, @@ -182,14 +180,11 @@ fn get_entry_by_name<'a>(rt: &'a Runtime, name: &str) -> Result>, rem: Option>) { let path = { match build_entry_path(rt.store(), id) { - Err(e) => { - trace_error(&e); - exit(1); - }, + Err(e) => trace_error_exit(&e, 1), Ok(s) => s, } }; @@ -97,10 +94,7 @@ fn alter(rt: &Runtime, id: &str, add: Option>, rem: Option>) { fn list(id: &str, rt: &Runtime) { let path = { match build_entry_path(rt.store(), id) { - Err(e) => { - trace_error(&e); - exit(1); - }, + Err(e) => trace_error_exit(&e, 1), Ok(s) => s, } }; @@ -116,8 +110,7 @@ fn list(id: &str, rt: &Runtime) { Err(e) => { debug!("Could not get '{:?}' => {:?}", id, path); warn!("Could not get entry '{}'", id); - trace_error(&e); - exit(1); + trace_error_exit(&e, 1); }, }; @@ -135,8 +128,7 @@ fn list(id: &str, rt: &Runtime) { let tags = entry.get_tags(); if tags.is_err() { - trace_error(&tags.unwrap_err()); - exit(1); + trace_error_exit(&tags.unwrap_err(), 1); } let tags = tags.unwrap(); diff --git a/imag-view/src/main.rs b/imag-view/src/main.rs index 2fa7802b..c0d4d180 100644 --- a/imag-view/src/main.rs +++ b/imag-view/src/main.rs @@ -30,7 +30,7 @@ use std::process::exit; use libimagrt::runtime::Runtime; use libimagrt::setup::generate_runtime_setup; use libimagstore::store::FileLockEntry; -use libimagerror::trace::trace_error; +use libimagerror::trace::{trace_error, trace_error_exit}; mod error; mod ui; @@ -54,8 +54,7 @@ fn main() { if rt.cli().is_present("versions") { if let Err(e) = view_versions_of(entry_id, &rt) { - trace_error(&e); - exit(1); // we can afford not-executing destructors here + trace_error_exit(&e, 1); } } else { let entry_version = rt.cli().value_of("version"); @@ -93,8 +92,7 @@ fn main() { let entry = load_entry(entry_id, entry_version, &rt); if entry.is_err() { - trace_error(&entry.unwrap_err()); - exit(1); // we can afford not-executing destructors here + trace_error_exit(&entry.unwrap_err(), 1); } let entry = entry.unwrap();