Plugins: Pass PluginEventInfo instead of PluginErrorEventArgs to ErrorHandler
This commit is contained in:
@@ -233,7 +233,7 @@ namespace Il2CppInspector.CLI
|
|||||||
|
|
||||||
// Set plugin handlers
|
// Set plugin handlers
|
||||||
PluginManager.ErrorHandler += (s, e) => {
|
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.");
|
+ " The application will continue but may not behave as expected.");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ namespace Il2CppInspector
|
|||||||
// Error handler called when a plugin throws an exception
|
// Error handler called when a plugin throws an exception
|
||||||
// This should be hooked by the client consuming the Il2CppInspector class library
|
// This should be hooked by the client consuming the Il2CppInspector class library
|
||||||
// If not used, all exceptions are suppressed (which is probably really bad)
|
// If not used, all exceptions are suppressed (which is probably really bad)
|
||||||
public static event EventHandler<PluginErrorEventArgs> ErrorHandler;
|
public static event EventHandler<PluginEventInfo> ErrorHandler;
|
||||||
|
|
||||||
// Handler called when a plugin reports a status update
|
// Handler called when a plugin reports a status update
|
||||||
// If not used, all status updates are suppressed
|
// If not used, all status updates are suppressed
|
||||||
@@ -232,7 +232,7 @@ namespace Il2CppInspector
|
|||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
eventInfo.Error = new PluginErrorEventArgs { Plugin = plugin, Exception = ex, Operation = "options update" };
|
eventInfo.Error = new PluginErrorEventArgs { Plugin = plugin, Exception = ex, Operation = "options update" };
|
||||||
ErrorHandler?.Invoke(AsInstance, eventInfo.Error);
|
ErrorHandler?.Invoke(AsInstance, eventInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return eventInfo;
|
return eventInfo;
|
||||||
@@ -254,7 +254,7 @@ namespace Il2CppInspector
|
|||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
eventInfo.Error = new PluginErrorEventArgs { Plugin = plugin, Exception = ex, Operation = typeof(I).Name };
|
eventInfo.Error = new PluginErrorEventArgs { Plugin = plugin, Exception = ex, Operation = typeof(I).Name };
|
||||||
ErrorHandler?.Invoke(AsInstance, eventInfo.Error);
|
ErrorHandler?.Invoke(AsInstance, eventInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return eventInfo;
|
return eventInfo;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using System.Windows;
|
|||||||
using System.Windows.Markup;
|
using System.Windows.Markup;
|
||||||
using Il2CppInspector;
|
using Il2CppInspector;
|
||||||
using Il2CppInspector.Model;
|
using Il2CppInspector.Model;
|
||||||
|
using Il2CppInspector.PluginAPI.V100;
|
||||||
using Il2CppInspector.Reflection;
|
using Il2CppInspector.Reflection;
|
||||||
using Inspector = Il2CppInspector.Il2CppInspector;
|
using Inspector = Il2CppInspector.Il2CppInspector;
|
||||||
|
|
||||||
@@ -83,7 +84,10 @@ namespace Il2CppInspectorGUI
|
|||||||
|
|
||||||
// Set handlers for plugin manager
|
// Set handlers for plugin manager
|
||||||
PluginManager.ErrorHandler += (s, e) => {
|
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");
|
+ Environment.NewLine + Environment.NewLine + "The application will continue but may not behave as expected.", "Plugin error");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -163,11 +163,16 @@ namespace Il2CppInspectorGUI
|
|||||||
|
|
||||||
// Check options validity before allowing the dialog to close either by clicking OK or the close icon
|
// 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) {
|
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)) {
|
if (!IsValid(lstOptions)) {
|
||||||
MessageBox.Show("One or more options are invalid.", "Il2CppInspector Plugin Configuration");
|
MessageBox.Show("One or more options are invalid.", "Il2CppInspector Plugin Configuration");
|
||||||
e.Cancel = true;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ namespace Il2CppInspector
|
|||||||
};
|
};
|
||||||
|
|
||||||
PluginManager.ErrorHandler += (s, e) => {
|
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 <plugins-id>.options.txt for each plugin in test folder
|
// Get plugin options - place desired options in <plugins-id>.options.txt for each plugin in test folder
|
||||||
|
|||||||
Reference in New Issue
Block a user