Log errors when a plugin's control throws exceptions instead of just letting WPF die.
Also add some new types for Essentials
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using NLog;
|
||||
using Torch.API;
|
||||
using Torch.API.Plugins;
|
||||
using Torch.Server.Views;
|
||||
@@ -17,13 +18,25 @@ namespace Torch.Server.ViewModels
|
||||
public string Name { get; }
|
||||
public ITorchPlugin Plugin { get; }
|
||||
|
||||
private static Logger _log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public PluginViewModel(ITorchPlugin plugin)
|
||||
{
|
||||
Plugin = plugin;
|
||||
|
||||
if (Plugin is IWpfPlugin p)
|
||||
Control = p.GetControl();
|
||||
|
||||
{
|
||||
try
|
||||
{
|
||||
Control = p.GetControl();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.Error(ex, $"Exception loading interface for plugin {Plugin.Name}! Plugin interface will not be available!");
|
||||
Control = null;
|
||||
}
|
||||
}
|
||||
|
||||
Name = $"{plugin.Name} ({plugin.Version})";
|
||||
|
||||
ThemeControl.UpdateDynamicControls += UpdateResourceDict;
|
||||
|
Reference in New Issue
Block a user