2015-01-11 21:52:30 +08:00
|
|
|
|
using System;
|
2016-05-10 05:45:20 +08:00
|
|
|
|
using System.Windows;
|
2015-01-11 21:52:30 +08:00
|
|
|
|
using System.Windows.Threading;
|
2015-11-09 09:32:33 +08:00
|
|
|
|
using Wox.Infrastructure.Exception;
|
2015-01-11 21:52:30 +08:00
|
|
|
|
using Wox.Infrastructure.Logger;
|
|
|
|
|
|
|
|
|
|
namespace Wox.Helper
|
|
|
|
|
{
|
|
|
|
|
public static class ErrorReporting
|
|
|
|
|
{
|
2015-01-16 23:42:12 +08:00
|
|
|
|
public static void Report(Exception e)
|
2015-01-11 21:52:30 +08:00
|
|
|
|
{
|
2015-11-08 01:32:58 +08:00
|
|
|
|
Log.Fatal(e);
|
2015-01-11 21:52:30 +08:00
|
|
|
|
new CrashReporter.CrashReporter(e).Show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e)
|
|
|
|
|
{
|
2015-01-16 23:42:12 +08:00
|
|
|
|
//handle non-ui thread exceptions
|
2016-05-10 05:45:20 +08:00
|
|
|
|
Application.Current.MainWindow.Dispatcher.Invoke(() =>
|
2015-01-16 23:42:12 +08:00
|
|
|
|
{
|
|
|
|
|
Report((Exception)e.ExceptionObject);
|
|
|
|
|
if (!(e.ExceptionObject is WoxException))
|
|
|
|
|
{
|
|
|
|
|
Environment.Exit(0);
|
|
|
|
|
}
|
2016-01-07 05:34:42 +08:00
|
|
|
|
});
|
2015-01-11 21:52:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
|
|
|
|
{
|
2015-01-16 23:42:12 +08:00
|
|
|
|
//handle ui thread exceptions
|
2015-01-11 21:52:30 +08:00
|
|
|
|
Report(e.Exception);
|
2015-01-16 23:42:12 +08:00
|
|
|
|
//prevent crash
|
|
|
|
|
e.Handled = true;
|
2015-01-11 21:52:30 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|