Skip to content

Commit 2f27fa6

Browse files
committed
Do not open report window for task scheduler exception
1 parent 3be057d commit 2f27fa6

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Flow.Launcher/App.xaml.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,8 @@ private static void RegisterAppDomainExceptions()
286286
}
287287

288288
/// <summary>
289-
/// let exception throw as normal is better for Debug
289+
/// exception will not be thrown normally, so we log it
290290
/// </summary>
291-
[Conditional("RELEASE")]
292291
private static void RegisterTaskSchedulerUnhandledException()
293292
{
294293
TaskScheduler.UnobservedTaskException += ErrorReporting.TaskSchedulerUnobservedTaskException;

Flow.Launcher/Helper/ErrorReporting.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Threading.Tasks;
3-
using System.Windows;
43
using System.Windows.Threading;
54
using Flow.Launcher.Infrastructure;
65
using Flow.Launcher.Infrastructure.Exception;
@@ -35,8 +34,11 @@ public static void DispatcherUnhandledException(object sender, DispatcherUnhandl
3534
public static void TaskSchedulerUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
3635
{
3736
//handle unobserved task exceptions
38-
Application.Current.Dispatcher.Invoke(() => Report(e.Exception));
37+
//do not open report window since it is not an unhandled exception
38+
var logger = LogManager.GetLogger("TaskSchedulerUnobservedException");
39+
logger.Fatal(ExceptionFormatter.FormatExcpetion(e.Exception));
3940
//prevent application exit, so the user can copy the prompted error info
41+
e.SetObserved();
4042
}
4143

4244
public static string RuntimeInfo()

0 commit comments

Comments
 (0)