diff options
| -rw-r--r-- | src/lib.rs | 4 | ||||
| -rw-r--r-- | src/main.rs | 5 |
2 files changed, 6 insertions, 3 deletions
@@ -191,8 +191,8 @@ pub struct Config { } impl Config { - pub fn load(toml: &str) -> Config { - toml::from_str(toml).expect("Couldn't parse config.toml") + pub fn load(toml: &str) -> Result<Config, toml::de::Error> { + toml::from_str(toml) } } diff --git a/src/main.rs b/src/main.rs index 74a5cca..424df39 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,7 +36,10 @@ async fn main() { error!(path = %args.config, error = %e, "Failed to read config file"); process::exit(1); }); - let config = Config::load(&content); + let config = Config::load(&content).unwrap_or_else(|e| { + error!(path = %args.config, error = %e, "Failed to parse config file"); + process::exit(1); + }); let state: StateMap = Arc::new(Mutex::new(HashMap::new())); let mut tasks = JoinSet::new(); let mut task_names: HashMap<Id, String> = HashMap::new(); |
