diff --git a/src/post_history/mod.rs b/src/post_history.rs similarity index 88% rename from src/post_history/mod.rs rename to src/post_history.rs index a1c8e68..3d0e245 100644 --- a/src/post_history/mod.rs +++ b/src/post_history.rs @@ -4,6 +4,7 @@ use std::fs::OpenOptions; use std::io::Write; use std::path::Path; use serde_derive::{Deserialize, Serialize}; +use crate::write_error; #[derive(Serialize, Deserialize, Clone, Debug)] pub(crate) struct SeriesHistory { @@ -11,7 +12,7 @@ pub(crate) struct SeriesHistory { } impl SeriesHistory { - pub(crate) fn load_history() -> Result { + pub(crate) fn load_history() -> Result { let path = confy::get_configuration_file_path(env!("CARGO_PKG_NAME"), "config").expect("Something went wrong with confy"); let config_dir = path.parent().expect("Something went wrong with confy"); @@ -21,7 +22,11 @@ impl SeriesHistory { true => { let file_contents: String = match fs::read_to_string("history.toml") { Ok(data) => data, - Err(e) => return Err(format!("{}", e)), + Err(e) => { + let err_msg = format!("{e}"); + write_error(err_msg); + return Err(()) + }, }; let history: Result = match file_contents.len() { @@ -33,7 +38,11 @@ impl SeriesHistory { match history { Ok(data) => Ok(data), - Err(e) => Err(format!("{}", e)) + Err(e) => { + let err_msg = format!("{e}"); + write_error(err_msg); + Err(()) + } } }, false => {