Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 2365167

Browse files
committed
improved updater exception handling visuals
1 parent c53e9cb commit 2365167

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

Interop/Updater/UpdateWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</controls:MetroWindow.Resources>
2121
<Grid>
2222
<TextBlock Name="MainLine" VerticalAlignment="Top" Margin="10,0,40,0" FontSize="16" Foreground="{DynamicResource AccentColorBrush}" IsHitTestVisible="False" />
23-
<TextBlock Name="SubLine" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="50,25,0,0" FontSize="14" Foreground="{DynamicResource AccentColorBrush}" IsHitTestVisible="False" />
23+
<TextBlock Name="SubLine" VerticalAlignment="Top" Margin="10,25,40,0" FontSize="14" Foreground="{DynamicResource AccentColorBrush}" IsHitTestVisible="False" />
2424
<Button Name="ActionYesButton" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,25,0,0" Width="50" Click="ActionYesButton_Click" />
2525
<Button Name="ActionNoButton" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="69,25,0,0" Width="50" Click="ActionNoButton_Click" />
2626
<FlowDocumentScrollViewer xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

Interop/Updater/UpdateWindow.xaml.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Windows.Input;
1010
using System.Windows.Media;
1111
using MahApps.Metro;
12+
using MahApps.Metro.Controls.Dialogs;
1213
using MdXaml;
1314
using SPCode.Utils;
1415

@@ -52,10 +53,12 @@ private void ActionNoButton_Click(object sender, RoutedEventArgs e)
5253
{
5354
Close();
5455
}
56+
5557
private void ActionGithubButton_Click(object sender, RoutedEventArgs e)
5658
{
5759
Process.Start(new ProcessStartInfo(Constants.GitHubLatestRelease));
5860
}
61+
5962
private void MetroWindow_KeyDown(object sender, KeyEventArgs e)
6063
{
6164
if (e.Key == Key.Escape)
@@ -157,13 +160,15 @@ private void UpdateDownloadWorker()
157160
client.DownloadFile(updater.BrowserDownloadUrl, updater.Name);
158161
client.DownloadFile(portable.BrowserDownloadUrl, portable.Name);
159162
}
160-
catch (Exception e)
163+
catch (Exception ex)
161164
{
162-
MessageBox.Show(
163-
"Error while downloading the updater." + Environment.NewLine + "Details: " + e.Message +
164-
Environment.NewLine + "$$$" + e.StackTrace,
165-
"Error", MessageBoxButton.OK, MessageBoxImage.Warning);
166-
Dispatcher.Invoke(Close);
165+
Dispatcher.Invoke(() =>
166+
{
167+
Program.MainWindow.ShowMessageAsync("Error while downloading the update assets",
168+
$"{ex.Message}", MessageDialogStyle.Affirmative, Program.MainWindow.MetroDialogOptions);
169+
Close();
170+
});
171+
return;
167172
}
168173

169174
Thread.Sleep(100);

Utils/DefaultTranslations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public class DefaultTranslations
243243
{ "No", "No" },
244244
{ "ViewGithub", "View on GitHub" },
245245
{ "UpdatingTo", "Updating to {0}" },
246-
{ "DownloadingUpdater", "Downloading updater..." },
246+
{ "DownloadingUpdater", "Downloading update assets..." },
247247
{ "StartingUpdater", "Starting updater..." },
248248
{ "Add", "Add" },
249249
{ "Remove", "Remove" },

0 commit comments

Comments
 (0)