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)
|
||||
}
|
||||
|
||||
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 {
|
||||
BlockMethod::EntireGame => {
|
||||
if Self::is_save_server_blocked().unwrap() {
|
||||
// ignoring the return because if this is an error the user can just thug it out at that point
|
||||
let _ = self.unblock_save_server();
|
||||
self.blocked = Self::is_exe_blocked().unwrap();
|
||||
if Self::is_save_server_blocked()? {
|
||||
self.unblock_save_server()?;
|
||||
self.blocked = Self::is_exe_blocked()?;
|
||||
}
|
||||
}
|
||||
BlockMethod::SaveServer => {
|
||||
if Self::is_exe_blocked().unwrap() {
|
||||
// ignoring the return because if this is an error the user can just thug it out at that point
|
||||
let _ = self.unblock_exe();
|
||||
self.blocked = Self::is_save_server_blocked().unwrap();
|
||||
if Self::is_exe_blocked()? {
|
||||
self.unblock_exe()?;
|
||||
self.blocked = Self::is_save_server_blocked()?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -256,8 +256,12 @@ impl App {
|
||||
ui.build_menu(&mut self.settings.block_method);
|
||||
});
|
||||
ui.label("Block method");
|
||||
self.game_networking
|
||||
.ensure_not_both_blocked_simultaneously(self.settings.block_method);
|
||||
if let Err(why) = self
|
||||
.game_networking
|
||||
.ensure_not_both_blocked_simultaneously(self.settings.block_method)
|
||||
{
|
||||
log::warn!("Couldn't ensure block exclusivity: {why}");
|
||||
};
|
||||
});
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_enabled_ui(
|
||||
|
||||
Reference in New Issue
Block a user