mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
Add crashreproter
This commit is contained in:
@@ -9,15 +9,28 @@ using System.Windows.Threading;
|
||||
using System.Xml;
|
||||
using Microsoft.Win32;
|
||||
using Wox.Infrastructure.Logger;
|
||||
using CrashReporterDotNET;
|
||||
|
||||
namespace Wox.Helper.ErrorReporting
|
||||
{
|
||||
public static class ErrorReporting
|
||||
{
|
||||
private static void ReportCrash(Exception exception)
|
||||
{
|
||||
var reportCrash = new ReportCrash
|
||||
{
|
||||
ToEmail = "qianlf2008@163.com"
|
||||
};
|
||||
|
||||
reportCrash.Send(exception);
|
||||
}
|
||||
|
||||
public static void UnhandledExceptionHandle(object sender, System.UnhandledExceptionEventArgs e)
|
||||
{
|
||||
if (System.Diagnostics.Debugger.IsAttached) return;
|
||||
|
||||
ReportCrash((Exception)e.ExceptionObject);
|
||||
return;
|
||||
string error = CreateExceptionReport("System.AppDomain.UnhandledException", e.ExceptionObject);
|
||||
|
||||
//e.IsTerminating is always true in most times, so try to avoid use this property
|
||||
@@ -30,6 +43,9 @@ namespace Wox.Helper.ErrorReporting
|
||||
{
|
||||
if (Debugger.IsAttached) return;
|
||||
|
||||
ReportCrash(e.Exception);
|
||||
return;
|
||||
|
||||
e.Handled = true;
|
||||
string error = CreateExceptionReport("System.Windows.Application.DispatcherUnhandledException", e.Exception);
|
||||
|
||||
@@ -39,7 +55,8 @@ namespace Wox.Helper.ErrorReporting
|
||||
public static void ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
|
||||
{
|
||||
if (Debugger.IsAttached) return;
|
||||
|
||||
ReportCrash(e.Exception);
|
||||
return;
|
||||
string error = CreateExceptionReport("System.Windows.Forms.Application.ThreadException", e.Exception);
|
||||
|
||||
Log.Fatal(error);
|
||||
@@ -271,6 +288,7 @@ namespace Wox.Helper.ErrorReporting
|
||||
var dialog = new WPFErrorReportingDialog(error, title, exceptionObject);
|
||||
dialog.ShowDialog();
|
||||
}
|
||||
|
||||
private static void ShowWPFMessageBox(string error, string title)
|
||||
{
|
||||
System.Windows.MessageBox.Show(error, title, MessageBoxButton.OK, MessageBoxImage.Error,
|
||||
|
||||
Reference in New Issue
Block a user