Skip to content

Commit

Permalink
now sending crash dumps ! -> 1.0.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
MaelElseware committed Aug 27, 2018
1 parent 72d315a commit 0f68abd
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 9 deletions.
44 changes: 44 additions & 0 deletions NaturalLauncher/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@

using System.Windows;
using System.Threading.Tasks;
using System.Windows.Threading;
using CrashReporterDotNET;
using System;

namespace NaturalLauncher
{
Expand All @@ -8,5 +12,45 @@ namespace NaturalLauncher
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
Application.Current.DispatcherUnhandledException += DispatcherOnUnhandledException;
TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;
}

private void TaskSchedulerOnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs unobservedTaskExceptionEventArgs)
{
SendReport(unobservedTaskExceptionEventArgs.Exception);
Environment.Exit(0);
}

private void DispatcherOnUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs dispatcherUnhandledExceptionEventArgs)
{
SendReport(dispatcherUnhandledExceptionEventArgs.Exception);
Environment.Exit(0);
}

private static void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs)
{
SendReport((Exception)unhandledExceptionEventArgs.ExceptionObject);
Environment.Exit(0);
}

public static void SendReport(Exception exception, string developerMessage = "")
{
var reportCrash = new ReportCrash("[email protected]"); // mail to send crash dumps to
reportCrash.DeveloperMessage = developerMessage;
reportCrash.DoctorDumpSettings = new DoctorDumpSettings
{
ApplicationID = new Guid("abac8312-371a-4fad-aa9d-b4b0cd5d11ab"),
};
/*var reportCrash = new ReportCrash("Email where you want to receive crash reports.")
{
DeveloperMessage = developerMessage
};*/
reportCrash.Send(exception);
}
}
}
7 changes: 5 additions & 2 deletions NaturalLauncher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ You should have received a copy of the GNU General Public License
using System.Windows.Media.Imaging;
using System.Windows.Resources;


namespace NaturalLauncher
{
/// <summary>
/// Logique d'interaction pour MainWindow.xaml
/// </summary>
///
public partial class MainWindow : Window
{
// TODO We need to know if ns files are being updated to lock the verify/update functions if so (with a file on the main serv).
Expand Down Expand Up @@ -78,13 +80,13 @@ public MainWindow()
IsDebugMode = true;
#endif

// Self Updater
SelfUpdater.DeleteOldFiles(); // not really needed since CleanAndLaunch.exe

SelfUpdater TheSelfUpdater = new SelfUpdater();
TheSelfUpdater.SetMainWindowRef(this);
TheSelfUpdater.UpdateLauncher();


if (SelfUpdater.LaucherRemoteVNumber != SelfUpdater.LaucherLocalVNumber && SelfUpdater.isSelfUpdating)
{
this.Hide();
Expand Down Expand Up @@ -216,7 +218,7 @@ private void Check_Version()
}
}

#region clicks
#region Clicks
private void Start_Click(object sender, RoutedEventArgs e)
{
if (SelfUpdater.CheckOneFileSignature("NaturalLauncher.exe") || !SelfUpdater.isSelfUpdating)
Expand Down Expand Up @@ -658,4 +660,5 @@ void webClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
#endregion

}

}
3 changes: 3 additions & 0 deletions NaturalLauncher/NaturalLauncher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
<SignManifests>true</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="CrashReporter.NET, Version=1.5.5.0, Culture=neutral, PublicKeyToken=7828e0fd88cab698, processorArchitecture=MSIL">
<HintPath>..\packages\CrashReporter.NET.Official.1.5.5\lib\net462\CrashReporter.NET.dll</HintPath>
</Reference>
<Reference Include="DiscordRPC, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\DiscordRPC.dll</HintPath>
Expand Down
18 changes: 11 additions & 7 deletions NaturalLauncher/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,13 @@ public static string RemoteVersion(string url)
rv = s;
}
}
catch (Exception)
catch (Exception exception)
{
// Anything could have happened here but
// we don't want to stop the user
// from using the application.
rv = null;
App.SendReport(exception, "Couldnt Find the Remote Version of NS");
}
return rv;
}
Expand Down Expand Up @@ -261,9 +262,10 @@ public static string GetShortTimeString()
}
}
}
catch
catch(Exception exception)
{
MessageBoxResult AlertBox = MessageBox.Show("HL Folder not found","Alert", MessageBoxButton.OK , MessageBoxImage.Error);
App.SendReport(exception, "Couldnt Find the Remote Version of NS");
path = "";
}

Expand Down Expand Up @@ -432,15 +434,15 @@ public static LauncherManifest GetIgnoreManifest(bool isVerification)
string IgnoreString = File.ReadAllText(IgnorePath);
NewManifest = JsonConvert.DeserializeObject<LauncherManifest>(IgnoreString);
}
catch
catch(Exception exception)
{
/*MessageBoxResult AlertBox = System.Windows.MessageBox.Show("Could not retrieve a new ignore manifest file, Creating a void one...");
NewManifest.Files["/config.cfg"] = "";*/
Util.PlaySoundFX("error");
MessageBoxResult AlertBox = System.Windows.MessageBox.Show("Launcher couldn't find a correct ignore.list from online source, please verify you internet connection..."
, "Alert", MessageBoxButton.OK, MessageBoxImage.Error);
throw new Exception("Launcher couldn't find a correct ignore.list from online source, please verify you internet connection...");

App.SendReport(exception, "Launcher couldn't find a correct ignore.list from online source, please verify you internet connection...");
}
}
// then we read the custom one on the disk
Expand Down Expand Up @@ -605,9 +607,10 @@ public static void ChangeAValueInCfg(string ValueName,string Value,bool isStrict
File.WriteAllLines(Launcher.NSFolder + Path.DirectorySeparatorChar + "config.cfg", CfgLines);
}
}
catch
catch(Exception exception)
{
System.Windows.MessageBox.Show("Could not write config.cfg, please verify the file is not read only !", "Read only", MessageBoxButton.OK, MessageBoxImage.Error);
App.SendReport(exception, "Could not write config.cfg, please verify the file is not read only !");
}
try
{
Expand All @@ -616,10 +619,11 @@ public static void ChangeAValueInCfg(string ValueName,string Value,bool isStrict
File.WriteAllLines(Launcher.NSFolder + Path.DirectorySeparatorChar + "userconfig.cfg", UCfgLines);
}
}
catch
catch (Exception exception)
{
System.Windows.MessageBox.Show("Could not write userconfig.cfg, please verify the file is not read only !" + Environment.NewLine +
"This problem may also be caused by a hud_style setting in your userconfig.cfg file !", "Read only", MessageBoxButton.OK, MessageBoxImage.Error);
App.SendReport(exception, "Could not write userconfig.cfg, please verify the file is not read only !");
}

}
Expand Down
1 change: 1 addition & 0 deletions NaturalLauncher/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CrashReporter.NET.Official" version="1.5.5" targetFramework="net462" />
<package id="HtmlAgilityPack" version="1.8.5" targetFramework="net462" />
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net462" />
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net462" />
Expand Down

0 comments on commit 0f68abd

Please sign in to comment.