mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Plugins UI - Improved error reporting on exceptions during enable
This commit is contained in:
1 parent
4e8d0bf70b
commit
66b1620441
6 files changed
+72
-36
No files matched your search
@@ -11,7 +11,7 @@ namespace Artemis.Core
|
||||
public abstract class PluginFeature : CorePropertyChanged, IDisposable
|
||||
{
|
||||
private bool _isEnabled;
|
||||
private Exception? _loadException;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin feature info related to this feature
|
||||
@@ -37,15 +37,6 @@ namespace Artemis.Core
|
||||
internal set => SetAndNotify(ref _isEnabled, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the exception thrown while loading
|
||||
/// </summary>
|
||||
public Exception? LoadException
|
||||
{
|
||||
get => _loadException;
|
||||
internal set => SetAndNotify(ref _loadException, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the identifier of this plugin feature
|
||||
/// </summary>
|
||||
@@ -149,10 +140,10 @@ namespace Artemis.Core
|
||||
if (isAutoEnable && GetLockFileCreated())
|
||||
{
|
||||
// Don't wrap existing lock exceptions, simply rethrow them
|
||||
if (LoadException is ArtemisPluginLockException)
|
||||
throw LoadException;
|
||||
if (Info.LoadException is ArtemisPluginLockException)
|
||||
throw Info.LoadException;
|
||||
|
||||
throw new ArtemisPluginLockException(LoadException);
|
||||
throw new ArtemisPluginLockException(Info.LoadException);
|
||||
}
|
||||
|
||||
CreateLockFile();
|
||||
@@ -165,21 +156,21 @@ namespace Artemis.Core
|
||||
if (!enableTask.Wait(TimeSpan.FromSeconds(15)))
|
||||
throw new ArtemisPluginException(Plugin, "Plugin load timeout");
|
||||
|
||||
LoadException = null;
|
||||
Info.LoadException = null;
|
||||
OnEnabled();
|
||||
}
|
||||
// If enable failed, put it back in a disabled state
|
||||
catch (Exception e)
|
||||
{
|
||||
IsEnabled = false;
|
||||
LoadException = e;
|
||||
Info.LoadException = e;
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Clean up the lock file unless the failure was due to the lock file
|
||||
// After all, we failed but not miserably :)
|
||||
if (!(LoadException is ArtemisPluginLockException))
|
||||
if (Info.LoadException is not ArtemisPluginLockException)
|
||||
DeleteLockFile();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace Artemis.Core
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class PluginFeatureInfo : CorePropertyChanged, IPrerequisitesSubject
|
||||
{
|
||||
private Exception? _loadException;
|
||||
private string? _description;
|
||||
private string? _icon;
|
||||
private PluginFeature? _instance;
|
||||
@@ -80,6 +81,15 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public Type FeatureType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the exception thrown while loading
|
||||
/// </summary>
|
||||
public Exception? LoadException
|
||||
{
|
||||
get => _loadException;
|
||||
internal set => SetAndNotify(ref _loadException, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of the plugin
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user