Skip to content

Commit

Permalink
fix: Also report toml loading failures with --watch
Browse files Browse the repository at this point in the history
* hot_reload crate (used for loading config.toml) does not report the ReloaderError we give, only that reloading failed with generic message "Failed to reload watch target" in WARN level
    * .. but WARN level of external crates are not logged by default => no log message when broken config and --watch is active
* => report our own log message more in line with non-watch mode and with detail about why loading failed
  • Loading branch information
Jonas Berlin authored and xkr47 committed Nov 3, 2024
1 parent dac1c38 commit f7753ec
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rpxy-bin/src/config/service.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::toml::ConfigToml;
use async_trait::async_trait;
use hot_reload::{Reload, ReloaderError};
use tracing::warn;

#[derive(Clone)]
pub struct ConfigTomlReloader {
Expand All @@ -17,8 +18,10 @@ impl Reload<ConfigToml> for ConfigTomlReloader {
}

async fn reload(&self) -> Result<Option<ConfigToml>, ReloaderError<ConfigToml>> {
let conf = ConfigToml::new(&self.config_path)
.map_err(|_e| ReloaderError::<ConfigToml>::Reload("Failed to reload config toml"))?;
let conf = ConfigToml::new(&self.config_path).map_err(|e| {
warn!("Invalid toml file: {e:?}");
ReloaderError::<ConfigToml>::Reload("Failed to reload config toml")
})?;
Ok(Some(conf))
}
}

0 comments on commit f7753ec

Please sign in to comment.