PowerToys/Wox/Helper/ErrorReporting.cs
bao-qian 646b7a3118 Refactoring error report
1. fix #627
2. fix #646
3. remove exceptionless
2016-05-20 21:16:25 +01:00

39 lines
1.0 KiB
C#

using System;
using System.Windows;
using System.Windows.Threading;
using Wox.Infrastructure.Exception;
using Wox.Infrastructure.Logger;
namespace Wox.Helper
{
public static class ErrorReporting
{
public static void Report(Exception e)
{
Log.Fatal(e);
new CrashReporter(e).Show();
}
public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e)
{
//handle non-ui thread exceptions
Application.Current.MainWindow.Dispatcher.Invoke(() =>
{
Report((Exception)e.ExceptionObject);
if (!(e.ExceptionObject is WoxException))
{
Environment.Exit(0);
}
});
}
public static void DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
//handle ui thread exceptions
Report(e.Exception);
//prevent crash
e.Handled = true;
}
}
}