Better exception report.

This commit is contained in:
qianlifeng
2015-01-16 23:42:12 +08:00
parent 32e0074f26
commit 9d39b616f9
12 changed files with 98 additions and 80 deletions

View File

@@ -5,31 +5,38 @@ using System.Windows.Forms;
using System.Windows.Threading;
using Wox.Core.Exception;
using Wox.Infrastructure.Logger;
using MessageBox = System.Windows.MessageBox;
namespace Wox.Helper
{
public static class ErrorReporting
{
private static void Report(Exception e)
public static void Report(Exception e)
{
//if (Debugger.IsAttached) return;
if (Debugger.IsAttached) return;
Log.Error(ExceptionFormatter.FormatExcpetion(e));
new CrashReporter.CrashReporter(e).Show();
}
public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e)
{
Report((Exception)e.ExceptionObject);
//handle non-ui thread exceptions
App.Window.Dispatcher.Invoke(new Action(() =>
{
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);
}
public static void ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
Report(e.Exception);
//prevent crash
e.Handled = true;
}
}
}