diff options
| author | Serguey Parkhomovsky <xindigo@gmail.com> | 2026-03-21 11:45:50 -0700 |
|---|---|---|
| committer | Serguey Parkhomovsky <xindigo@gmail.com> | 2026-03-21 11:45:50 -0700 |
| commit | ea7307674cfdc630785da43c97213c8c774f3f36 (patch) | |
| tree | e0d51efd7240a5989bf7070e23d11f283af49af5 /src | |
| parent | f6d3e56b4ed829286ddc8590f3d4afda01753000 (diff) | |
Return result when failing to parse config.toml
Diffstat (limited to 'src')
| -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(); |
