diff --git a/Il2CppInspector.CLI/Program.cs b/Il2CppInspector.CLI/Program.cs index d3af8a6..2e591d2 100644 --- a/Il2CppInspector.CLI/Program.cs +++ b/Il2CppInspector.CLI/Program.cs @@ -233,7 +233,7 @@ namespace Il2CppInspector.CLI // Set plugin handlers PluginManager.ErrorHandler += (s, e) => { - Console.Error.WriteLine($"The plugin {e.Plugin.Name} encountered an error while executing {e.Operation}: {e.Exception.Message}." + Console.Error.WriteLine($"The plugin {e.Error.Plugin.Name} encountered an error while executing {e.Error.Operation}: {e.Error.Exception.Message}." + " The application will continue but may not behave as expected."); }; diff --git a/Il2CppInspector.Common/Plugins/PluginManager.cs b/Il2CppInspector.Common/Plugins/PluginManager.cs index e8a8835..a91f1f6 100644 --- a/Il2CppInspector.Common/Plugins/PluginManager.cs +++ b/Il2CppInspector.Common/Plugins/PluginManager.cs @@ -113,7 +113,7 @@ namespace Il2CppInspector // Error handler called when a plugin throws an exception // This should be hooked by the client consuming the Il2CppInspector class library // If not used, all exceptions are suppressed (which is probably really bad) - public static event EventHandler ErrorHandler; + public static event EventHandler ErrorHandler; // Handler called when a plugin reports a status update // If not used, all status updates are suppressed @@ -232,7 +232,7 @@ namespace Il2CppInspector } catch (Exception ex) { eventInfo.Error = new PluginErrorEventArgs { Plugin = plugin, Exception = ex, Operation = "options update" }; - ErrorHandler?.Invoke(AsInstance, eventInfo.Error); + ErrorHandler?.Invoke(AsInstance, eventInfo); } return eventInfo; @@ -254,7 +254,7 @@ namespace Il2CppInspector } catch (Exception ex) { eventInfo.Error = new PluginErrorEventArgs { Plugin = plugin, Exception = ex, Operation = typeof(I).Name }; - ErrorHandler?.Invoke(AsInstance, eventInfo.Error); + ErrorHandler?.Invoke(AsInstance, eventInfo); } return eventInfo; diff --git a/Il2CppInspector.GUI/App.xaml.cs b/Il2CppInspector.GUI/App.xaml.cs index 7f7e7fd..f8e4e67 100644 --- a/Il2CppInspector.GUI/App.xaml.cs +++ b/Il2CppInspector.GUI/App.xaml.cs @@ -15,6 +15,7 @@ using System.Windows; using System.Windows.Markup; using Il2CppInspector; using Il2CppInspector.Model; +using Il2CppInspector.PluginAPI.V100; using Il2CppInspector.Reflection; using Inspector = Il2CppInspector.Il2CppInspector; @@ -83,7 +84,10 @@ namespace Il2CppInspectorGUI // Set handlers for plugin manager PluginManager.ErrorHandler += (s, e) => { - MessageBox.Show($"The plugin {e.Plugin.Name} encountered an error while executing {e.Operation}: {e.Exception.Message}." + if (e is PluginOptionsChangedEventInfo) + MessageBox.Show("Could not update plugin options. " + e.Error.Exception.Message, "Plugin error"); + else + MessageBox.Show($"The plugin {e.Error.Plugin.Name} encountered an error while executing {e.Error.Operation}: {e.Error.Exception.Message}." + Environment.NewLine + Environment.NewLine + "The application will continue but may not behave as expected.", "Plugin error"); }; diff --git a/Il2CppInspector.GUI/PluginConfigurationDialog.xaml.cs b/Il2CppInspector.GUI/PluginConfigurationDialog.xaml.cs index cf3593c..20a62a2 100644 --- a/Il2CppInspector.GUI/PluginConfigurationDialog.xaml.cs +++ b/Il2CppInspector.GUI/PluginConfigurationDialog.xaml.cs @@ -163,11 +163,16 @@ namespace Il2CppInspectorGUI // Check options validity before allowing the dialog to close either by clicking OK or the close icon private void Window_Closing(object sender, CancelEventArgs e) { + // Don't allow the window to close if any of the options are invalid if (!IsValid(lstOptions)) { MessageBox.Show("One or more options are invalid.", "Il2CppInspector Plugin Configuration"); e.Cancel = true; + return; } - PluginManager.OptionsChanged(Plugin); + + // Don't allow window to close if the options couldn't be updated + if (PluginManager.OptionsChanged(Plugin).Error != null) + e.Cancel = true; } } } diff --git a/Il2CppTests/TestRunner.cs b/Il2CppTests/TestRunner.cs index 15c549b..439b1c2 100644 --- a/Il2CppTests/TestRunner.cs +++ b/Il2CppTests/TestRunner.cs @@ -75,7 +75,7 @@ namespace Il2CppInspector }; PluginManager.ErrorHandler += (s, e) => { - Assert.Fail($"{e.Plugin.Name} throw an exception during {e.Operation}: {e.Exception.Message}.", e); + Assert.Fail($"{e.Error.Plugin.Name} throw an exception during {e.Error.Operation}: {e.Error.Exception.Message}.", e); }; // Get plugin options - place desired options in .options.txt for each plugin in test folder