Add Exception Handling for Querying plugins results

This commit is contained in:
张弘韬 2021-01-01 21:19:05 +08:00
parent 29a382085f
commit f1badd6ae2

View file

@ -21,6 +21,7 @@ using Flow.Launcher.Plugin.SharedCommands;
using Flow.Launcher.Storage;
using System.Windows.Media;
using Flow.Launcher.Infrastructure.Image;
using Flow.Launcher.Infrastructure.Logger;
namespace Flow.Launcher.ViewModel
{
@ -414,8 +415,15 @@ namespace Flow.Launcher.ViewModel
{
if (!plugin.Metadata.Disabled)
{
var results = PluginManager.QueryForPlugin(plugin, query);
UpdateResultView(results, plugin.Metadata, query);
try
{
var results = PluginManager.QueryForPlugin(plugin, query);
UpdateResultView(results, plugin.Metadata, query);
}
catch(Exception e)
{
Log.Exception($"|MainViewModel|Exception when querying {plugin.Metadata.Name}", e);
}
}
});
}
@ -432,7 +440,10 @@ namespace Flow.Launcher.ViewModel
{ // update to hidden if this is still the current query
ProgressBarVisibility = Visibility.Hidden;
}
}, currentCancellationToken);
}, currentCancellationToken).ContinueWith(t =>
{
Log.Exception("|MainViewModel|Error when querying plugin", t.Exception?.InnerException);
}, TaskContinuationOptions.OnlyOnFaulted);
}
}
else