From 841e6a34a49261d2681c8a4d2c1dc176ba4e3b35 Mon Sep 17 00:00:00 2001 From: Ben Morrison Date: Tue, 26 May 2020 23:15:51 -0400 Subject: 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. --- src/logging.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'src/logging.rs') 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<()> { -- cgit 1.4.1-2-gfad0