Remove some useless code for error reporting

This commit is contained in:
bao-qian
2017-04-01 12:49:02 +01:00
parent cc6c18b5ad
commit bf4c4561ce
5 changed files with 23 additions and 45 deletions

View File

@@ -29,8 +29,6 @@ namespace Wox
[STAThread]
public static void Main()
{
RegisterAppDomainExceptions();
if (SingleInstance<App>.InitializeAsFirstInstance(Unique))
{
using (var application = new App())
@@ -45,7 +43,9 @@ namespace Wox
{
Stopwatch.Normal("|App.OnStartup|Startup cost", () =>
{
Log.Info("|App.OnStartup|Begin Wox startup ----------------------------------------------------");
Log.Info("|App.Main|Begin Wox startup ----------------------------------------------------");
Log.Info($"|App.OnStartup|{ErrorReporting.RuntimeInfo()}");
RegisterAppDomainExceptions();
RegisterDispatcherUnhandledException();
ImageLoader.Initialize();

View File

@@ -1,26 +0,0 @@
using System;
namespace Wox
{
public class CrashReporter
{
private Exception exception;
public CrashReporter(Exception e)
{
exception = e;
}
public void Show()
{
if (exception == null) return;
if (exception.InnerException != null)
{
exception = exception.InnerException;
}
ReportWindow reportWindow = new ReportWindow(exception);
reportWindow.Show();
}
}
}

View File

@@ -1,27 +1,25 @@
using System;
using System.Windows;
using System.Windows.Threading;
using NLog;
using Wox.Infrastructure;
using Wox.Infrastructure.Exception;
namespace Wox.Helper
{
public static class ErrorReporting
{
public static void Report(Exception e)
private static void Report(Exception e)
{
var logger = LogManager.GetLogger("UnHandledException");
logger.Fatal(ExceptionFormatter.FormatExcpetion(e));
new CrashReporter(e).Show();
var reportWindow = new ReportWindow(e);
reportWindow.Show();
}
public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e)
{
//handle non-ui thread exceptions
Application.Current.MainWindow.Dispatcher.Invoke(() =>
{
Report((Exception)e.ExceptionObject);
});
Report((Exception)e.ExceptionObject);
}
public static void DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
@@ -29,5 +27,16 @@ namespace Wox.Helper
//handle ui thread exceptions
Report(e.Exception);
}
public static string RuntimeInfo()
{
var info = $"\nWox version: {Constant.Version}" +
$"\nOS Version: {Environment.OSVersion.VersionString}" +
$"\nIntPtr Length: {IntPtr.Size}" +
$"\nx64: {Environment.Is64BitOperatingSystem}" +
$"\nPython Path: {Constant.PythonPath}" +
$"\nEverything SDK Path: {Constant.EverythingSDKPath}";
return info;
}
}
}

View File

@@ -6,6 +6,7 @@ using System.Text;
using System.Linq;
using System.Windows;
using System.Windows.Documents;
using Wox.Helper;
using Wox.Infrastructure;
using Wox.Infrastructure.Logger;
@@ -26,18 +27,13 @@ namespace Wox
var directory = new DirectoryInfo(path);
var log = directory.GetFiles().OrderByDescending(f => f.LastWriteTime).First();
var paragraph = Hyperlink("Please open new issue in: " , Constant.Issue);
var paragraph = Hyperlink("Please open new issue in: ", Constant.Issue);
paragraph.Inlines.Add($"1. upload log file: {log.FullName}\n");
paragraph.Inlines.Add($"2. copy below exception message");
ErrorTextbox.Document.Blocks.Add(paragraph);
StringBuilder content = new StringBuilder();
content.AppendLine($"Wox version: {Constant.Version}");
content.AppendLine($"OS Version: {Environment.OSVersion.VersionString}");
content.AppendLine($"IntPtr Length: {IntPtr.Size}");
content.AppendLine($"x64: {Environment.Is64BitOperatingSystem}");
content.AppendLine($"Python Path: {Constant.PythonPath}");
content.AppendLine($"Everything SDK Path: {Constant.EverythingSDKPath}");
content.AppendLine(ErrorReporting.RuntimeInfo());
content.AppendLine($"Date: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}");
content.AppendLine("Exception:");
content.AppendLine(exception.Source);
@@ -54,7 +50,7 @@ namespace Wox
var paragraph = new Paragraph();
paragraph.Margin = new Thickness(0);
var link = new Hyperlink {IsEnabled = true};
var link = new Hyperlink { IsEnabled = true };
link.Inlines.Add(url);
link.NavigateUri = new Uri(url);
link.RequestNavigate += (s, e) => Process.Start(e.Uri.ToString());

View File

@@ -158,7 +158,6 @@
<Compile Include="..\SolutionAssemblyInfo.cs">
<Link>Properties\SolutionAssemblyInfo.cs</Link>
</Compile>
<Compile Include="CrashReporter.cs" />
<Compile Include="Helper\SingletonWindowOpener.cs" />
<Compile Include="PublicAPIInstance.cs" />
<Compile Include="ReportWindow.xaml.cs" />