Skip to content

Commit 4e4707a

Browse files
authored
Merge branch 'dev' into file_tooltip
2 parents 32b75b4 + 524fb6a commit 4e4707a

File tree

4 files changed

+71
-51
lines changed

4 files changed

+71
-51
lines changed

Flow.Launcher/Helper/ErrorReporting.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
using System;
22
using System.Runtime.CompilerServices;
33
using System.Threading.Tasks;
4-
using System.Windows;
54
using System.Windows.Threading;
65
using Flow.Launcher.Infrastructure;
76
using Flow.Launcher.Infrastructure.Exception;
7+
using Flow.Launcher.Infrastructure.Logger;
88
using NLog;
99

1010
namespace Flow.Launcher.Helper;
1111

1212
public static class ErrorReporting
1313
{
14-
private static void Report(Exception e, [CallerMemberName] string methodName = "UnHandledException")
14+
private static void Report(Exception e, bool silent = false, [CallerMemberName] string methodName = "UnHandledException")
1515
{
1616
var logger = LogManager.GetLogger(methodName);
1717
logger.Fatal(ExceptionFormatter.FormatExcpetion(e));
18+
if (silent) return;
1819
var reportWindow = new ReportWindow(e);
1920
reportWindow.Show();
2021
}
@@ -35,8 +36,9 @@ public static void DispatcherUnhandledException(object sender, DispatcherUnhandl
3536

3637
public static void TaskSchedulerUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
3738
{
38-
// handle unobserved task exceptions on UI thread
39-
Application.Current.Dispatcher.Invoke(() => Report(e.Exception));
39+
// log exception but do not handle unobserved task exceptions on UI thread
40+
//Application.Current.Dispatcher.Invoke(() => Report(e.Exception, true));
41+
Log.Exception(nameof(ErrorReporting), "Unobserved task exception occurred.", e.Exception);
4042
// prevent application exit, so the user can copy the prompted error info
4143
e.SetObserved();
4244
}

Flow.Launcher/PublicAPIInstance.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public Task<Stream> HttpGetStreamAsync(string url, CancellationToken token = def
251251
Http.GetStreamAsync(url, token);
252252

253253
public Task HttpDownloadAsync([NotNull] string url, [NotNull] string filePath, Action<double> reportProgress = null,
254-
CancellationToken token = default) =>Http.DownloadAsync(url, filePath, reportProgress, token);
254+
CancellationToken token = default) => Http.DownloadAsync(url, filePath, reportProgress, token);
255255

256256
public void AddActionKeyword(string pluginId, string newActionKeyword) =>
257257
PluginManager.AddActionKeyword(pluginId, newActionKeyword);

Flow.Launcher/Themes/Base.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@
108108
<Style x:Key="BasePendingLineStyle" TargetType="{x:Type Line}">
109109
<Setter Property="Stroke" Value="{StaticResource SystemAccentColorLight1Brush}" />
110110
</Style>
111+
<Style
112+
x:Key="PendingLineStyle"
113+
BasedOn="{StaticResource BasePendingLineStyle}"
114+
TargetType="{x:Type Line}" />
111115

112116
<Style x:Key="BaseClockPanelPosition" TargetType="{x:Type Canvas}" />
113117

Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs

Lines changed: 60 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -316,61 +316,75 @@ where string.Compare(existingPlugin.Metadata.Version, pluginUpdateSource.Version
316316
var downloadToFilePath = Path.Combine(Path.GetTempPath(),
317317
$"{x.Name}-{x.NewVersion}.zip");
318318

319-
_ = Task.Run(async delegate
319+
_ = Task.Run(async () =>
320320
{
321-
using var cts = new CancellationTokenSource();
322-
323-
if (!x.PluginNewUserPlugin.IsFromLocalInstallPath)
324-
{
325-
await DownloadFileAsync(
326-
$"{Context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin")} {x.PluginNewUserPlugin.Name}",
327-
x.PluginNewUserPlugin.UrlDownload, downloadToFilePath, cts);
328-
}
329-
else
321+
try
330322
{
331-
downloadToFilePath = x.PluginNewUserPlugin.LocalInstallPath;
332-
}
323+
using var cts = new CancellationTokenSource();
333324

334-
// check if user cancelled download before installing plugin
335-
if (cts.IsCancellationRequested)
336-
{
337-
return;
338-
}
339-
else
340-
{
341-
await Context.API.UpdatePluginAsync(x.PluginExistingMetadata, x.PluginNewUserPlugin,
342-
downloadToFilePath);
325+
if (!x.PluginNewUserPlugin.IsFromLocalInstallPath)
326+
{
327+
await DownloadFileAsync(
328+
$"{Context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin")} {x.PluginNewUserPlugin.Name}",
329+
x.PluginNewUserPlugin.UrlDownload, downloadToFilePath, cts);
330+
}
331+
else
332+
{
333+
downloadToFilePath = x.PluginNewUserPlugin.LocalInstallPath;
334+
}
343335

344-
if (Settings.AutoRestartAfterChanging)
336+
// check if user cancelled download before installing plugin
337+
if (cts.IsCancellationRequested)
345338
{
346-
Context.API.ShowMsg(
347-
Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
348-
string.Format(
349-
Context.API.GetTranslation(
350-
"plugin_pluginsmanager_update_success_restart"),
351-
x.Name));
352-
Context.API.RestartApp();
339+
return;
353340
}
354341
else
355342
{
356-
Context.API.ShowMsg(
357-
Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
358-
string.Format(
359-
Context.API.GetTranslation(
360-
"plugin_pluginsmanager_update_success_no_restart"),
361-
x.Name));
343+
await Context.API.UpdatePluginAsync(x.PluginExistingMetadata, x.PluginNewUserPlugin,
344+
downloadToFilePath);
345+
346+
if (Settings.AutoRestartAfterChanging)
347+
{
348+
Context.API.ShowMsg(
349+
Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
350+
string.Format(
351+
Context.API.GetTranslation(
352+
"plugin_pluginsmanager_update_success_restart"),
353+
x.Name));
354+
Context.API.RestartApp();
355+
}
356+
else
357+
{
358+
Context.API.ShowMsg(
359+
Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
360+
string.Format(
361+
Context.API.GetTranslation(
362+
"plugin_pluginsmanager_update_success_no_restart"),
363+
x.Name));
364+
}
362365
}
363366
}
364-
}).ContinueWith(t =>
365-
{
366-
Context.API.LogException(ClassName, $"Update failed for {x.Name}",
367-
t.Exception.InnerException);
368-
Context.API.ShowMsg(
369-
Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"),
370-
string.Format(
371-
Context.API.GetTranslation("plugin_pluginsmanager_install_error_subtitle"),
372-
x.Name));
373-
}, token, TaskContinuationOptions.OnlyOnFaulted, TaskScheduler.Default);
367+
catch (HttpRequestException e)
368+
{
369+
// show error message
370+
Context.API.ShowMsgError(
371+
string.Format(Context.API.GetTranslation("plugin_pluginsmanager_downloading_plugin"), x.Name),
372+
Context.API.GetTranslation("plugin_pluginsmanager_download_error"));
373+
Context.API.LogException(ClassName, "An error occurred while downloading plugin", e);
374+
return;
375+
}
376+
catch (Exception e)
377+
{
378+
// show error message
379+
Context.API.LogException(ClassName, $"Update failed for {x.Name}", e);
380+
Context.API.ShowMsgError(
381+
Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"),
382+
string.Format(
383+
Context.API.GetTranslation("plugin_pluginsmanager_install_error_subtitle"),
384+
x.Name));
385+
return;
386+
}
387+
});
374388

375389
return true;
376390
},
@@ -436,7 +450,7 @@ await Context.API.UpdatePluginAsync(plugin.PluginExistingMetadata, plugin.Plugin
436450
catch (Exception ex)
437451
{
438452
Context.API.LogException(ClassName, $"Update failed for {plugin.Name}", ex.InnerException);
439-
Context.API.ShowMsg(
453+
Context.API.ShowMsgError(
440454
Context.API.GetTranslation("plugin_pluginsmanager_install_error_title"),
441455
string.Format(
442456
Context.API.GetTranslation("plugin_pluginsmanager_install_error_subtitle"),

0 commit comments

Comments
 (0)