From ecbcc5923f22766d0b7e73d070451b26c92eb75f Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Thu, 21 May 2020 08:47:09 +1000 Subject: [PATCH] Add error message to inform user of failed plugins --- Flow.Launcher.Core/Plugin/PluginsLoader.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Flow.Launcher.Core/Plugin/PluginsLoader.cs b/Flow.Launcher.Core/Plugin/PluginsLoader.cs index c6c357de0..1f6a17573 100644 --- a/Flow.Launcher.Core/Plugin/PluginsLoader.cs +++ b/Flow.Launcher.Core/Plugin/PluginsLoader.cs @@ -29,6 +29,8 @@ namespace Flow.Launcher.Core.Plugin public static IEnumerable DotNetPlugins(List source) { + var erroredPlugins = new List(); + var plugins = new List(); var metadatas = source.Where(o => AllowedLanguage.IsDotNet(o.Language)); @@ -50,6 +52,8 @@ namespace Flow.Launcher.Core.Plugin } catch (Exception e) { + erroredPlugins.Add(metadata.Name); + Log.Exception($"|PluginsLoader.DotNetPlugins|Couldn't load assembly for {metadata.Name}", e); return; } @@ -63,11 +67,15 @@ namespace Flow.Launcher.Core.Plugin } catch (InvalidOperationException e) { + erroredPlugins.Add(metadata.Name); + Log.Exception($"|PluginsLoader.DotNetPlugins|Can't find class implement IPlugin for <{metadata.Name}>", e); return; } catch (ReflectionTypeLoadException e) { + erroredPlugins.Add(metadata.Name); + Log.Exception($"|PluginsLoader.DotNetPlugins|The GetTypes method was unable to load assembly types for <{metadata.Name}>", e); return; } @@ -79,6 +87,7 @@ namespace Flow.Launcher.Core.Plugin } catch (Exception e) { + erroredPlugins.Add(metadata.Name); Log.Exception($"|PluginsLoader.DotNetPlugins|Can't create instance for <{metadata.Name}>", e); return; } @@ -93,6 +102,19 @@ namespace Flow.Launcher.Core.Plugin metadata.InitTime += milliseconds; } + + if (erroredPlugins.Count > 0) + { + var errorPluginString = ""; + + erroredPlugins.ForEach(x => errorPluginString += x + Environment.NewLine); + + Task.Run(() => + { + MessageBox.Show($"Uh oh, unable to load plugins:{Environment.NewLine}{errorPluginString}"); + }); + } + return plugins; }