better error handling of block exclusivity
This commit is contained in:
@@ -138,23 +138,25 @@ impl GameNetworking {
|
|||||||
Self::is_blocked_generic(FILTER_NAME_SAVE_SERVER)
|
Self::is_blocked_generic(FILTER_NAME_SAVE_SERVER)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ensure_not_both_blocked_simultaneously(&mut self, block_method: BlockMethod) {
|
pub fn ensure_not_both_blocked_simultaneously(
|
||||||
|
&mut self,
|
||||||
|
block_method: BlockMethod,
|
||||||
|
) -> Result<(), Box<dyn Error>> {
|
||||||
match block_method {
|
match block_method {
|
||||||
BlockMethod::EntireGame => {
|
BlockMethod::EntireGame => {
|
||||||
if Self::is_save_server_blocked().unwrap() {
|
if Self::is_save_server_blocked()? {
|
||||||
// ignoring the return because if this is an error the user can just thug it out at that point
|
self.unblock_save_server()?;
|
||||||
let _ = self.unblock_save_server();
|
self.blocked = Self::is_exe_blocked()?;
|
||||||
self.blocked = Self::is_exe_blocked().unwrap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BlockMethod::SaveServer => {
|
BlockMethod::SaveServer => {
|
||||||
if Self::is_exe_blocked().unwrap() {
|
if Self::is_exe_blocked()? {
|
||||||
// ignoring the return because if this is an error the user can just thug it out at that point
|
self.unblock_exe()?;
|
||||||
let _ = self.unblock_exe();
|
self.blocked = Self::is_save_server_blocked()?;
|
||||||
self.blocked = Self::is_save_server_blocked().unwrap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-2
@@ -256,8 +256,12 @@ impl App {
|
|||||||
ui.build_menu(&mut self.settings.block_method);
|
ui.build_menu(&mut self.settings.block_method);
|
||||||
});
|
});
|
||||||
ui.label("Block method");
|
ui.label("Block method");
|
||||||
self.game_networking
|
if let Err(why) = self
|
||||||
.ensure_not_both_blocked_simultaneously(self.settings.block_method);
|
.game_networking
|
||||||
|
.ensure_not_both_blocked_simultaneously(self.settings.block_method)
|
||||||
|
{
|
||||||
|
log::warn!("Couldn't ensure block exclusivity: {why}");
|
||||||
|
};
|
||||||
});
|
});
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.add_enabled_ui(
|
ui.add_enabled_ui(
|
||||||
|
|||||||
Reference in New Issue
Block a user