Skip to content

Commit 23a5030

Browse files
author
janekdererste
committed
Improve error message when loading config ffailes
1 parent 13eb108 commit 23a5030

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/simulation/config.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ pub struct Config {
2626

2727
impl Config {
2828
pub fn from_file(args: &CommandLineArgs) -> Self {
29-
let reader = BufReader::new(File::open(&args.config_path).expect("Failed to open file."));
29+
let reader = BufReader::new(File::open(&args.config_path).unwrap_or_else(|e| {
30+
panic!(
31+
"Failed to open config file at {}. Original error was {}",
32+
args.config_path, e
33+
);
34+
}));
3035
let mut config: Config = serde_yaml::from_reader(reader).unwrap_or_else(|e| {
3136
panic!(
3237
"Failed to parse config at {}. Original error was: {}",

0 commit comments

Comments
 (0)