mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 04:07:40 +02:00
Remove some useless code for error reporting
This commit is contained in:
@@ -29,8 +29,6 @@ namespace Wox
|
|||||||
[STAThread]
|
[STAThread]
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
RegisterAppDomainExceptions();
|
|
||||||
|
|
||||||
if (SingleInstance<App>.InitializeAsFirstInstance(Unique))
|
if (SingleInstance<App>.InitializeAsFirstInstance(Unique))
|
||||||
{
|
{
|
||||||
using (var application = new App())
|
using (var application = new App())
|
||||||
@@ -45,7 +43,9 @@ namespace Wox
|
|||||||
{
|
{
|
||||||
Stopwatch.Normal("|App.OnStartup|Startup cost", () =>
|
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();
|
RegisterDispatcherUnhandledException();
|
||||||
|
|
||||||
ImageLoader.Initialize();
|
ImageLoader.Initialize();
|
||||||
|
|||||||
@@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +1,25 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
using Wox.Infrastructure;
|
||||||
using Wox.Infrastructure.Exception;
|
using Wox.Infrastructure.Exception;
|
||||||
|
|
||||||
namespace Wox.Helper
|
namespace Wox.Helper
|
||||||
{
|
{
|
||||||
public static class ErrorReporting
|
public static class ErrorReporting
|
||||||
{
|
{
|
||||||
public static void Report(Exception e)
|
private static void Report(Exception e)
|
||||||
{
|
{
|
||||||
var logger = LogManager.GetLogger("UnHandledException");
|
var logger = LogManager.GetLogger("UnHandledException");
|
||||||
logger.Fatal(ExceptionFormatter.FormatExcpetion(e));
|
logger.Fatal(ExceptionFormatter.FormatExcpetion(e));
|
||||||
new CrashReporter(e).Show();
|
var reportWindow = new ReportWindow(e);
|
||||||
|
reportWindow.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e)
|
public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e)
|
||||||
{
|
{
|
||||||
//handle non-ui thread exceptions
|
//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)
|
public static void DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
||||||
@@ -29,5 +27,16 @@ namespace Wox.Helper
|
|||||||
//handle ui thread exceptions
|
//handle ui thread exceptions
|
||||||
Report(e.Exception);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System.Text;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Documents;
|
using System.Windows.Documents;
|
||||||
|
using Wox.Helper;
|
||||||
using Wox.Infrastructure;
|
using Wox.Infrastructure;
|
||||||
using Wox.Infrastructure.Logger;
|
using Wox.Infrastructure.Logger;
|
||||||
|
|
||||||
@@ -26,18 +27,13 @@ namespace Wox
|
|||||||
var directory = new DirectoryInfo(path);
|
var directory = new DirectoryInfo(path);
|
||||||
var log = directory.GetFiles().OrderByDescending(f => f.LastWriteTime).First();
|
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($"1. upload log file: {log.FullName}\n");
|
||||||
paragraph.Inlines.Add($"2. copy below exception message");
|
paragraph.Inlines.Add($"2. copy below exception message");
|
||||||
ErrorTextbox.Document.Blocks.Add(paragraph);
|
ErrorTextbox.Document.Blocks.Add(paragraph);
|
||||||
|
|
||||||
StringBuilder content = new StringBuilder();
|
StringBuilder content = new StringBuilder();
|
||||||
content.AppendLine($"Wox version: {Constant.Version}");
|
content.AppendLine(ErrorReporting.RuntimeInfo());
|
||||||
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($"Date: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}");
|
content.AppendLine($"Date: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}");
|
||||||
content.AppendLine("Exception:");
|
content.AppendLine("Exception:");
|
||||||
content.AppendLine(exception.Source);
|
content.AppendLine(exception.Source);
|
||||||
@@ -54,7 +50,7 @@ namespace Wox
|
|||||||
var paragraph = new Paragraph();
|
var paragraph = new Paragraph();
|
||||||
paragraph.Margin = new Thickness(0);
|
paragraph.Margin = new Thickness(0);
|
||||||
|
|
||||||
var link = new Hyperlink {IsEnabled = true};
|
var link = new Hyperlink { IsEnabled = true };
|
||||||
link.Inlines.Add(url);
|
link.Inlines.Add(url);
|
||||||
link.NavigateUri = new Uri(url);
|
link.NavigateUri = new Uri(url);
|
||||||
link.RequestNavigate += (s, e) => Process.Start(e.Uri.ToString());
|
link.RequestNavigate += (s, e) => Process.Start(e.Uri.ToString());
|
||||||
|
|||||||
@@ -158,7 +158,6 @@
|
|||||||
<Compile Include="..\SolutionAssemblyInfo.cs">
|
<Compile Include="..\SolutionAssemblyInfo.cs">
|
||||||
<Link>Properties\SolutionAssemblyInfo.cs</Link>
|
<Link>Properties\SolutionAssemblyInfo.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="CrashReporter.cs" />
|
|
||||||
<Compile Include="Helper\SingletonWindowOpener.cs" />
|
<Compile Include="Helper\SingletonWindowOpener.cs" />
|
||||||
<Compile Include="PublicAPIInstance.cs" />
|
<Compile Include="PublicAPIInstance.cs" />
|
||||||
<Compile Include="ReportWindow.xaml.cs" />
|
<Compile Include="ReportWindow.xaml.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user