Skip to content

Commit

Permalink
zenohd-default config error #1292 (#1298)
Browse files Browse the repository at this point in the history
* Zenohd panic when tring load file

When zenohd trying load file, if it have a problem it crash cause another treat was "unwrap", and it return to a type config. So, it crash and cause painic.

* zenohd default config error #1292

When tring load config file defined by -c option. With haver any problema "unwrap" has been to Config type.

I treat it return a Default Config whe it happen

* If file fail when try load configs

If file fail when try load configs

* Update main.rs

* Resolve typos at comment

Resolve typos at comment
  • Loading branch information
anhaabaete authored Aug 12, 2024
1 parent fef38dc commit e66745e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion zenohd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ fn config_from_args(args: &Args) -> Config {
.config
.as_ref()
.map_or_else(Config::default, |conf_file| {
Config::from_file(conf_file).unwrap()
Config::from_file(conf_file).unwrap_or_else(|e| {
// if file load fail, wanning it, and load default config
tracing::warn!("Warn: File {} not found! {}", conf_file, e.to_string());
Config::default()
})
});

if config.mode().is_none() {
Expand Down

0 comments on commit e66745e

Please sign in to comment.