Skip to content

Commit 0883798

Browse files
committedMay 31, 2018
adds create issue on github if installation fails
1 parent a0994c0 commit 0883798

File tree

1 file changed

+31
-11
lines changed

1 file changed

+31
-11
lines changed
 

‎Src/BridgeVs.VsPackage/Package/BridgeVsPackage.cs

+31-11
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,17 @@
2525

2626
using System;
2727
using System.ComponentModel.Design;
28-
using System.Diagnostics;
2928
using System.Runtime.InteropServices;
3029
using System.Security.Principal;
3130
using System.Windows;
32-
using BridgeVs.Locations;
3331
using BridgeVs.VsPackage.Helper;
3432
using BridgeVs.VsPackage.Helper.Configuration;
3533
using BridgeVs.VsPackage.Helper.Installer;
3634
using BridgeVs.VsPackage.Helper.Settings;
3735
using EnvDTE;
3836
using Microsoft.VisualStudio;
39-
using Microsoft.VisualStudio.Settings;
4037
using Microsoft.VisualStudio.Shell;
4138
using Microsoft.VisualStudio.Shell.Interop;
42-
using Microsoft.VisualStudio.Shell.Settings;
4339

4440
namespace BridgeVs.VsPackage.Package
4541
{
@@ -72,6 +68,12 @@ public sealed class BridgeVsPackage : Microsoft.VisualStudio.Shell.Package
7268
//if this is not null means vs has to restart
7369
private Welcome _welcomePage;
7470
private bool? _installationResult;
71+
private class Error
72+
{
73+
public string Body;
74+
public string Title;
75+
}
76+
private Error _error;
7577
public static bool IsElevated => new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
7678
private PackageSettings _packageSettings;
7779
#region Package Members
@@ -120,7 +122,7 @@ protected override void Initialize()
120122
mcs.AddCommand(menuItemSendFeedback);
121123
//Initialize Object Exporter settings
122124
_packageSettings = (PackageSettings)GetDialogPage(typeof(PackageSettings));
123-
125+
124126
try
125127
{ //if first time user
126128
if (isLinqBridgeVsConfigured)
@@ -144,28 +146,46 @@ protected override void Initialize()
144146
}
145147
catch (Exception e)
146148
{
147-
Trace.Write("LINQBridgeVs: Initialize Error... " + e.Message);
148-
Trace.Write(e.StackTrace);
149-
MessageBox.Show($"LINQBridgeVs: Configuration unsuccessful. Please open a new issue on GitHub. Error: {e.Message}");
149+
_error = new Error();
150+
_error.Body = $"{e.Message} %0A {e.StackTrace}";
151+
_error.Title = "Error during installation. 1.4.6";
152+
Exception innerException = e.InnerException;
153+
while (innerException != null)
154+
{
155+
_error.Body += $"%0A {innerException.Message} {innerException.StackTrace}";
156+
innerException = innerException.InnerException;
157+
}
158+
_error.Body = _error.Body.Replace(Environment.NewLine, "%0A");
150159
}
151160
}
152161

153162
private void _dteEvents_OnStartupComplete()
154163
{
155164
_welcomePage?.Show();
165+
166+
if (_error != null)
167+
{
168+
var boxresult = MessageBox.Show($"Configuration unsuccessful. Do you want to open an issue on GitHub?", "LINQBridgeVs: Error during the configuration", MessageBoxButton.YesNo);
169+
if (boxresult == MessageBoxResult.Yes)
170+
{
171+
System.Diagnostics.Process.Start($"https://github.com/codingadventures/LINQBridgeVs/issues/new?title={_error.Title}&body={_error.Body}");
172+
}
173+
_error = null;
174+
}
175+
156176
if (_installationResult == null)
157177
return;
158178

159-
var messageResult = MessageBox.Show("Do you want to send anonymous error reports to LINQBridgeVs?", "LINQBridgeVs", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);
179+
var messageResult = MessageBox.Show("Do you want to send anonymous error reports to LINQBridgeVs?", "LINQBridgeVs: Error Tracking", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);
160180

161181
_packageSettings.ErrorTrackingEnabled = messageResult == MessageBoxResult.Yes;
162182
_packageSettings.SaveSettingsToStorage();
163183

164184
MessageBox.Show(_installationResult.Value
165185
? "LINQBridgeVs has been successfully configured."
166-
: "LINQBridgeVs wasn't successfully configured. Please check the logs in the output folder");
186+
: "LINQBridgeVs wasn't successfully configured.");
167187
}
168-
188+
169189
#endregion
170190
}
171191
}

0 commit comments

Comments
 (0)
Please sign in to comment.