From 1527c9fe176828a61f982ff4aed07f9626f3d074 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Fri, 25 Dec 2020 22:31:16 +0100 Subject: [PATCH] Plugins: Disable plugin automatically if it throws an exception --- Il2CppInspector.CLI/Program.cs | 2 +- Il2CppInspector.Common/Plugins/PluginManager.cs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Il2CppInspector.CLI/Program.cs b/Il2CppInspector.CLI/Program.cs index 2e591d2..b51d978 100644 --- a/Il2CppInspector.CLI/Program.cs +++ b/Il2CppInspector.CLI/Program.cs @@ -234,7 +234,7 @@ namespace Il2CppInspector.CLI // Set plugin handlers PluginManager.ErrorHandler += (s, e) => { 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."); + + " Plugin has been disabled."); }; PluginManager.StatusHandler += (s, e) => { diff --git a/Il2CppInspector.Common/Plugins/PluginManager.cs b/Il2CppInspector.Common/Plugins/PluginManager.cs index 8864103..22a15eb 100644 --- a/Il2CppInspector.Common/Plugins/PluginManager.cs +++ b/Il2CppInspector.Common/Plugins/PluginManager.cs @@ -262,6 +262,10 @@ namespace Il2CppInspector break; } catch (Exception ex) { + // Disable failing plugin + Plugins[plugin.Id].Enabled = false; + + // Forward error to error handler eventInfo.Error = new PluginErrorEventArgs { Plugin = plugin, Exception = ex, Operation = typeof(I).Name }; ErrorHandler?.Invoke(AsInstance, eventInfo); }