Skip to content

Commit ecbcc59

Browse files
committed
Add error message to inform user of failed plugins
1 parent 960593e commit ecbcc59

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Flow.Launcher.Core/Plugin/PluginsLoader.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public static List<PluginPair> Plugins(List<PluginMetadata> metadatas, PluginsSe
2929

3030
public static IEnumerable<PluginPair> DotNetPlugins(List<PluginMetadata> source)
3131
{
32+
var erroredPlugins = new List<string>();
33+
3234
var plugins = new List<PluginPair>();
3335
var metadatas = source.Where(o => AllowedLanguage.IsDotNet(o.Language));
3436

@@ -50,6 +52,8 @@ public static IEnumerable<PluginPair> DotNetPlugins(List<PluginMetadata> source)
5052
}
5153
catch (Exception e)
5254
{
55+
erroredPlugins.Add(metadata.Name);
56+
5357
Log.Exception($"|PluginsLoader.DotNetPlugins|Couldn't load assembly for {metadata.Name}", e);
5458
return;
5559
}
@@ -63,11 +67,15 @@ public static IEnumerable<PluginPair> DotNetPlugins(List<PluginMetadata> source)
6367
}
6468
catch (InvalidOperationException e)
6569
{
70+
erroredPlugins.Add(metadata.Name);
71+
6672
Log.Exception($"|PluginsLoader.DotNetPlugins|Can't find class implement IPlugin for <{metadata.Name}>", e);
6773
return;
6874
}
6975
catch (ReflectionTypeLoadException e)
7076
{
77+
erroredPlugins.Add(metadata.Name);
78+
7179
Log.Exception($"|PluginsLoader.DotNetPlugins|The GetTypes method was unable to load assembly types for <{metadata.Name}>", e);
7280
return;
7381
}
@@ -79,6 +87,7 @@ public static IEnumerable<PluginPair> DotNetPlugins(List<PluginMetadata> source)
7987
}
8088
catch (Exception e)
8189
{
90+
erroredPlugins.Add(metadata.Name);
8291
Log.Exception($"|PluginsLoader.DotNetPlugins|Can't create instance for <{metadata.Name}>", e);
8392
return;
8493
}
@@ -93,6 +102,19 @@ public static IEnumerable<PluginPair> DotNetPlugins(List<PluginMetadata> source)
93102
metadata.InitTime += milliseconds;
94103

95104
}
105+
106+
if (erroredPlugins.Count > 0)
107+
{
108+
var errorPluginString = "";
109+
110+
erroredPlugins.ForEach(x => errorPluginString += x + Environment.NewLine);
111+
112+
Task.Run(() =>
113+
{
114+
MessageBox.Show($"Uh oh, unable to load plugins:{Environment.NewLine}{errorPluginString}");
115+
});
116+
}
117+
96118
return plugins;
97119
}
98120

0 commit comments

Comments
 (0)