PowerToys/Wox/Helper/ErrorReporting.cs

50 lines
1.6 KiB
C#
Raw Normal View History

2015-01-11 21:52:30 +08:00
using System;
using System.Windows.Threading;
2017-01-24 08:24:20 +08:00
using NLog;
using Wox.Infrastructure;
2015-11-09 09:32:33 +08:00
using Wox.Infrastructure.Exception;
2015-01-11 21:52:30 +08:00
namespace Wox.Helper
{
public static class ErrorReporting
{
private static void Report(Exception e)
2015-01-11 21:52:30 +08:00
{
2017-01-24 08:24:20 +08:00
var logger = LogManager.GetLogger("UnHandledException");
logger.Fatal(ExceptionFormatter.FormatExcpetion(e));
var reportWindow = new ReportWindow(e);
reportWindow.Show();
2015-01-11 21:52:30 +08:00
}
public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e)
{
2015-01-16 23:42:12 +08:00
//handle non-ui thread exceptions
Report((Exception)e.ExceptionObject);
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);
2017-04-01 20:13:53 +08:00
//prevent application exist, so the user can copy prompted error info
e.Handled = true;
2015-01-11 21:52:30 +08:00
}
public static string RuntimeInfo()
{
var info = $"\nWox version: {Constant.Version}" +
$"\nOS Version: {Environment.OSVersion.VersionString}" +
$"\nIntPtr Length: {IntPtr.Size}" +
$"\nx64: {Environment.Is64BitOperatingSystem}";
return info;
}
public static string DependenciesInfo()
{
var info = $"\nPython Path: {Constant.PythonPath}" +
$"\nEverything SDK Path: {Constant.EverythingSDKPath}";
return info;
}
2015-01-11 21:52:30 +08:00
}
}