added finer error catching

pull/2/head
Nickiel12 1 year ago
parent 8b17e76d42
commit 40131dcad8

@ -16,7 +16,21 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Opening Config file: {}", args.config_file);
println!("File exists: {}", std::fs::metadata(args.config_file.clone()).is_ok());
let cfg: Config = toml::from_str(std::fs::read_to_string(args.config_file)?.as_str())?;
let file_contents = match std::fs::read_to_string(args.config_file) {
Ok(val) => val,
Err(e) => {
println!("Could not read file: {}", e.to_string());
return Ok(());
}
};
let cfg: Config = match toml::from_str(file_contents.as_str()) {
Ok(val) => val,
Err(e) => {
println!("Could not parse file: {}", e.to_string());
return Ok(());
}
};
let mut body_content: String = format!("*Last Updated:* {} \n", chrono::Local::now().format("%D - %H:%M:%S"));

Loading…
Cancel
Save