src/window_manager: return error instead of panic in `try_reload_config` when lua_path is not found
Browse files
+4 −5 src/window_manager.rs
| @@ -346,11 +346,10 @@ impl WindowManager { | |||
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | fn try_reload_config(&mut self) -> Result<(), String> { | 348 | fn try_reload_config(&mut self) -> Result<(), String> { |
| 349 | - let lua_path = self | 349 | + let lua_path = |
| 350 | - .config | 350 | + self.config.path.take().ok_or( |
| 351 | - .path | 351 | + "Could not find config file. Config path should've been set while loading", |
| 352 | - .take() | 352 | + )?; |
| 353 | - .expect("Could not find config file. Config path should've been set while loading"); | ||
| 354 | 353 | ||
| 355 | if !lua_path.exists() { | 354 | if !lua_path.exists() { |
| 356 | return Err("Could not find config file, has it been moved?".to_string()); | 355 | return Err("Could not find config file, has it been moved?".to_string()); |