more readable parser error messages, closes #47 (#49)

This commit is contained in:
Mustafa Salih 2021-04-25 20:28:50 +03:00 committed by GitHub
parent ba1a60cc62
commit cc0c16a3d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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(),
}