11using System ;
22using System . Runtime . CompilerServices ;
33using System . Threading . Tasks ;
4- using System . Windows ;
54using System . Windows . Threading ;
65using Flow . Launcher . Infrastructure ;
76using Flow . Launcher . Infrastructure . Exception ;
7+ using Flow . Launcher . Infrastructure . Logger ;
88using NLog ;
99
1010namespace Flow . Launcher . Helper ;
1111
1212public 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 }
0 commit comments