From cc0c16a3d0179156059971303779263bfc450d35 Mon Sep 17 00:00:00 2001 From: Mustafa Salih <37256744+MustafaSalih1993@users.noreply.github.com> Date: Sun, 25 Apr 2021 20:28:50 +0300 Subject: [PATCH] more readable parser error messages, closes #47 (#49) --- src/config/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/config/mod.rs b/src/config/mod.rs index 1fa35ba..202e50b 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -44,7 +44,13 @@ lazy_static! { Ok(mut file) => { file.read_to_string(&mut data) .expect("Failed to read config to string"); - serde_yaml::from_str(&data).expect("Failed to parse config") + serde_yaml::from_str(&data).unwrap_or_else(move |e| { + eprintln!( + "Failed to parse config: {}\nloading defaults!", + e.to_string() + ); + Config::default() + }) } Err(_) => Config::default(), }