|
|
@@ -323,12 +323,11 @@ impl WindowManager { |
| 323 |
323 |
let monitor_y = monitor.screen_y as i16; |
| 324 |
324 |
let screen_width = monitor.screen_width as u16; |
| 325 |
325 |
let screen_height = monitor.screen_height as u16; |
| 326 |
|
- let error = format!("{error}"); |
| 327 |
326 |
|
| 328 |
327 |
if let Err(e) = self.overlay.show_error( |
| 329 |
328 |
&self.connection, |
| 330 |
329 |
&self.font, |
| 331 |
|
- error.as_str(), |
|
330 |
+ error, |
| 332 |
331 |
monitor_x, |
| 333 |
332 |
monitor_y, |
| 334 |
333 |
screen_width, |
|
|
@@ -338,23 +337,23 @@ impl WindowManager { |
| 338 |
337 |
} |
| 339 |
338 |
} |
| 340 |
339 |
|
| 341 |
|
- fn try_reload_config(&mut self) -> Result<(), String> { |
| 342 |
|
- let lua_path = |
| 343 |
|
- self.config.path.as_ref().ok_or( |
| 344 |
|
- "Could not find config file. Config path should've been set while loading", |
| 345 |
|
- )?; |
|
340 |
+ fn try_reload_config(&mut self) -> Result<(), ConfigError> { |
|
341 |
+ let lua_path = self |
|
342 |
+ .config |
|
343 |
+ .path |
|
344 |
+ .as_ref() |
|
345 |
+ .ok_or(ConfigError::NoConfigPathSet)?; |
| 346 |
346 |
|
| 347 |
347 |
if !lua_path.exists() { |
| 348 |
|
- return Err("Could not find config file, has it been moved?".to_string()); |
|
348 |
+ return Err(ConfigError::NoConfigAtPath); |
| 349 |
349 |
} |
| 350 |
350 |
|
| 351 |
|
- let config_str = std::fs::read_to_string(lua_path) |
| 352 |
|
- .map_err(|e| format!("Failed to read config: {}", e))?; |
|
351 |
+ let config_str = |
|
352 |
+ std::fs::read_to_string(lua_path).map_err(|e| ConfigError::CouldNotReadConfig(e))?; |
| 353 |
353 |
|
| 354 |
354 |
let config_dir = lua_path.parent(); |
| 355 |
355 |
|
| 356 |
|
- let new_config = crate::config::parse_lua_config(&config_str, config_dir) |
| 357 |
|
- .map_err(|e| format!("{}", e))?; |
|
356 |
+ let new_config = crate::config::parse_lua_config(&config_str, config_dir)?; |
| 358 |
357 |
|
| 359 |
358 |
let lua_path = self.config.path.take(); |
| 360 |
359 |
|
|
|
@@ -2881,7 +2880,7 @@ impl WindowManager { |
| 2881 |
2880 |
} |
| 2882 |
2881 |
Err(err) => { |
| 2883 |
2882 |
eprintln!("Config reload error: {}", err); |
| 2884 |
|
- self.error_message = Some(err.clone()); |
|
2883 |
+ self.error_message = Some(err.to_string()); |
| 2885 |
2884 |
let monitor = &self.monitors[self.selected_monitor]; |
| 2886 |
2885 |
let monitor_x = monitor.screen_x as i16; |
| 2887 |
2886 |
let monitor_y = monitor.screen_y as i16; |
|
|
@@ -2890,7 +2889,7 @@ impl WindowManager { |
| 2890 |
2889 |
match self.overlay.show_error( |
| 2891 |
2890 |
&self.connection, |
| 2892 |
2891 |
&self.font, |
| 2893 |
|
- &err, |
|
2892 |
+ err, |
| 2894 |
2893 |
monitor_x, |
| 2895 |
2894 |
monitor_y, |
| 2896 |
2895 |
screen_width, |