Skip to content

Commit

Permalink
Improve Boilerplate windows client's exception handling (#8622)
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmoradi committed Sep 14, 2024
1 parent a6e30ca commit 6ccd57b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ private void App_DispatcherUnhandledException(object sender, System.Windows.Thre
{
((MainWindow)MainWindow).AppWebView.Services.GetRequiredService<IExceptionHandler>().Handle(e.Exception);
}
catch { }
catch
{
var errorMessage = e.Exception.ToString();
System.Windows.Clipboard.SetText(errorMessage);
System.Windows.Forms.MessageBox.Show(errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

e.Handled = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public static void Main(string[] args)
var application = new App();
Task.Run(async () =>
{
var services = await App.Current.Dispatcher.InvokeAsync(() => ((MainWindow)App.Current.MainWindow).AppWebView.Services);
try
{
var services = await App.Current.Dispatcher.InvokeAsync(() => ((MainWindow)App.Current.MainWindow).AppWebView.Services);
var windowsUpdateSettings = services.GetRequiredService<IOptionsSnapshot<WindowsUpdateSettings>>().Value;
if (windowsUpdateSettings?.FilesUrl is null)
if (string.IsNullOrEmpty(windowsUpdateSettings?.FilesUrl))
{
return;
}
Expand All @@ -43,7 +43,10 @@ public static void Main(string[] args)
}
}
}
catch { }
catch (Exception exp)
{
services.GetRequiredService<IExceptionHandler>().Handle(exp);
}
});
application.Run();
}
Expand Down

0 comments on commit 6ccd57b

Please sign in to comment.