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