@@ -337,13 +337,13 @@ public static void SaveSessionTabs() // Enumerates through all tabs and gets the
337337 }
338338
339339 // Occurs when an exception is not handled on the UI thread.
340- private static void OnUnhandledException ( object sender , Microsoft . UI . Xaml . UnhandledExceptionEventArgs e ) => AppUnhandledException ( e . Exception ) ;
340+ private static void OnUnhandledException ( object sender , Microsoft . UI . Xaml . UnhandledExceptionEventArgs e ) => AppUnhandledException ( e . Exception , true ) ;
341341
342342 // Occurs when an exception is not handled on a background thread.
343343 // ie. A task is fired and forgotten Task.Run(() => {...})
344- private static void OnUnobservedException ( object sender , UnobservedTaskExceptionEventArgs e ) => AppUnhandledException ( e . Exception ) ;
344+ private static void OnUnobservedException ( object sender , UnobservedTaskExceptionEventArgs e ) => AppUnhandledException ( e . Exception , false ) ;
345345
346- private static void AppUnhandledException ( Exception ex )
346+ private static void AppUnhandledException ( Exception ex , bool shouldShowNotification )
347347 {
348348 StringBuilder formattedException = new StringBuilder ( ) { Capacity = 200 } ;
349349
@@ -385,49 +385,50 @@ private static void AppUnhandledException(Exception ex)
385385
386386 SaveSessionTabs ( ) ;
387387 Logger . UnhandledError ( ex , ex . Message ) ;
388- if ( ShowErrorNotification )
388+
389+ if ( ! ShowErrorNotification || ! shouldShowNotification )
390+ return ;
391+
392+ var toastContent = new ToastContent ( )
389393 {
390- var toastContent = new ToastContent ( )
394+ Visual = new ToastVisual ( )
391395 {
392- Visual = new ToastVisual ( )
396+ BindingGeneric = new ToastBindingGeneric ( )
393397 {
394- BindingGeneric = new ToastBindingGeneric ( )
398+ Children =
395399 {
396- Children =
400+ new AdaptiveText ( )
397401 {
398- new AdaptiveText ( )
399- {
400- Text = "ExceptionNotificationHeader" . GetLocalizedResource ( )
401- } ,
402- new AdaptiveText ( )
403- {
404- Text = "ExceptionNotificationBody" . GetLocalizedResource ( )
405- }
402+ Text = "ExceptionNotificationHeader" . GetLocalizedResource ( )
406403 } ,
407- AppLogoOverride = new ToastGenericAppLogo ( )
404+ new AdaptiveText ( )
408405 {
409- Source = "ms-appx:///Assets/error.png"
406+ Text = "ExceptionNotificationBody" . GetLocalizedResource ( )
410407 }
408+ } ,
409+ AppLogoOverride = new ToastGenericAppLogo ( )
410+ {
411+ Source = "ms-appx:///Assets/error.png"
411412 }
412- } ,
413- Actions = new ToastActionsCustom ( )
413+ }
414+ } ,
415+ Actions = new ToastActionsCustom ( )
416+ {
417+ Buttons =
414418 {
415- Buttons =
419+ new ToastButton ( "ExceptionNotificationReportButton" . GetLocalizedResource ( ) , "report" )
416420 {
417- new ToastButton ( "ExceptionNotificationReportButton" . GetLocalizedResource ( ) , "report" )
418- {
419- ActivationType = ToastActivationType . Foreground
420- }
421+ ActivationType = ToastActivationType . Foreground
421422 }
422423 }
423- } ;
424+ }
425+ } ;
424426
425- // Create the toast notification
426- var toastNotif = new ToastNotification ( toastContent . GetXml ( ) ) ;
427+ // Create the toast notification
428+ var toastNotif = new ToastNotification ( toastContent . GetXml ( ) ) ;
427429
428- // And send the notification
429- ToastNotificationManager . CreateToastNotifier ( ) . Show ( toastNotif ) ;
430- }
430+ // And send the notification
431+ ToastNotificationManager . CreateToastNotifier ( ) . Show ( toastNotif ) ;
431432 }
432433
433434 public static void CloseApp ( )
0 commit comments