diff options
author | Ben Morrison <ben@gbmor.dev> | 2020-05-26 23:15:51 -0400 |
---|---|---|
committer | Ben Morrison <ben@gbmor.dev> | 2020-05-26 23:54:14 -0400 |
commit | 841e6a34a49261d2681c8a4d2c1dc176ba4e3b35 (patch) | |
tree | 726d6f77657ea79740a32c0ae55db88242591172 /src/logging.rs | |
parent | 8ecc2943a4241d466a9bf5a359260a958e3d3b46 (diff) | |
download | clinte-841e6a34a49261d2681c8a4d2c1dc176ba4e3b35.tar.gz |
removed panics and refactored error handling
Using a helper function to handle fatal errors error::helper() Displays the simplified message if an error condition occurs. Displays both the simplified and the raw error message if -v verbose logging is enabled.
Diffstat (limited to 'src/logging.rs')
-rw-r--r-- | src/logging.rs | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/src/logging.rs b/src/logging.rs index 5d3f378..d748117 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -2,20 +2,12 @@ use std::fs::OpenOptions; use simplelog::*; -use crate::conf; use crate::error; use crate::user; pub fn checked_init() { let logfile = format!("/tmp/clinte_{}.log", *user::NAME); - - if let Err(e) = init(&logfile) { - log::error!("Couldn't initialize logging. Exiting."); - if *conf::DEBUG { - log::error!("--> {}", e); - } - std::process::exit(1); - } + error::helper(init(&logfile), "Couldn't initialize logging"); } fn init(path: &str) -> error::Result<()> { |