PowerToys/Wox/Helper/ErrorReporting.cs
bao-qian 705354a3d6 Better logger
1. Throw exception for fatal/error log when debugging
2. Write to debug output for warn/debug/info log when debugging
3. part of #355
2015-11-07 17:32:58 +00:00

38 lines
1.0 KiB
C#

using System;
using System.Windows.Threading;
using Wox.Core.Exception;
using Wox.Infrastructure.Logger;
namespace Wox.Helper
{
public static class ErrorReporting
{
public static void Report(Exception e)
{
Log.Fatal(e);
new CrashReporter.CrashReporter(e).Show();
}
public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e)
{
//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);
//prevent crash
e.Handled = true;
}
}
}